1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Dear Visitor, we are presently having a membership drive and as a result EVERY new member that registers an account and makes THREE meaningful posts will have a mighty $10,000$ forum credits added to their wallets ... GET YOURS NOW!
    Dismiss Notice
  3. IMSpot.Org is under new management and we look forward to bringing you a range of exciting enhancements in coming days.
    Dismiss Notice
  4. Dear Visitors, why not register an account now and say hello ... we really would love to hear from you?
    Dismiss Notice
  5. Welcome to IMSpot.Org an internet marketing forum and very friendly place for discussion, learning and help in your online endeavours ... please consider joining our internet marketing community and sharing your knowledge with our members.
    Dismiss Notice

How do I solve common date problems?

Discussion in 'PHP' started by beingchinmay, Jul 19, 2016.

Tags:
  1. beingchinmay

    beingchinmay An Active Forum Member

    Joined:
    Jun 24, 2015
    Messages:
    28
    Likes Received:
    1
    Consider the types of calculations our brains make each time we’re confronted with a calendar:

    It’s clear there’s more to dealing with dates than simply organizing data in order of significance, or displaying an individual datum. In this solution, we’ll look at some of the common problems you may encounter when dealing with dates and times. In particular, we’ll see how to deal with

    1. days of the week
    2. weeks of the year
    3. days of the year
    4. the number of days in a month
    5. leap years
    In the process, we’ll build a class that can be easily reused in your own applications.

    The following code lays the foundation for the class:

    The constructor checks to see whether you’ve passed any values for a date, the arguments appearing in the order year, month, day, hour, minute and finally second. Any parameter for which you fail to provide a numeric value will assume the current date or time. The constructor then turns this into a timestamp, which will make later calculations easier.
     
Loading...
Live Thread addon by sonnb

Share This Page