Time And Date In PHP5
Applications that deal with PHP are ever present, especially in web-based application: times of form submittals, user input such as date of birth, and the updating and removal of pages when out of date are just a few examples. Although potentially complicated, the date extensions in PHP are relatively simple and straightforward.
This lesson deals primarily with the core date and time functions. These function provide all basic for time manipulation which is retrieving, formatting, and converting. One other extension, the calendar functions, is devoted to conversion between different calendar systems, such as converting dates between the Gregorian and Jewish calendars. After this you can see the function cal_to_jd () and cal_from_jd () on my Quick code below.
Here any moment in time is store as a simple integer. Time, when stored this way, is often referred to as a time stamp. As you will see, many functions either return a time stamp or use a time stamp as a parameter. You must be careful however, when reading documentation or code comments. Depending on context, the term time stamp can also be used in its more generic sense: a time at which something occurs. For example, when referring to web server log files, the time at which an event is logged is referred to as a time stamp.
Get the time stamp for the current time:
$ timestamp = time ();
Taking no parameter, this function returns the time stamp of the current time-that is, when time () is called.
Get the current time stamp to the microsecond resolution:
$ result = microtime ($ format);
Return the UNIX time stamp but resolved to microseconds in accuracy. If $ format is false, the default, the time is returned as the string "seconds microseconds" with the seconds portion of the same as that returned by time (), and microseconds as a fraction of a second. If $ format is true, the time is returned as a floating point number.