Application that deal with are forever 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. Though potentially complicated, the date extensions in PHP are relatively simple and straightforward.
This lesson deals mainly 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 fucntion cal_to_jd() and cal_from_jd() on my Quick code below.
Subject beyond the scope of this chapter is that of schedule or calendar management, such as meeting and event scheduling. An extension is available, called MCAL, which does provide such functionality. for more information, see http://php.net/mcal.
To fully utilize the time functionality of PHP, you must understand how PHP measures time. For PHP, time is measured as the number of seconds since January 1, 1970, theUNIX epoch.
Hence 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 reffered to as a time stamp.
This i add a Quick hits of function in time and date in PHP
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);
retun 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 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.
Create a time stamp for a specified date and time:
$timestamp =mktime($hour,$minute,$second,$month,$day,$year);
Return a time stamp that corresponds to the specified time and date.
Format the specified time:
$string = date($format,$timestamp);
Return a string representing the given time stamp based on the specified format. If $timestamp is not specified,the current time is used.
Format a date and time, adjusting the result to be Greenwich Mean Time(GMT):
$string = gmdate($format,$timestamp);
This function is equivalent to date(), the time is adjusted to be relative to GMT representation of the given time.
Get various information about a specified time:
$time_array = getdate($timestamp);
returns an array of various values based on the given time stamp. The keys to the are array seconds,minutes,hours,mday,wday,mon,year,yday,weekday
,month.
Get and set the time zone used by the time functions:
$string = date_default_timezone_get();
date_default_timezone_set($string);
This pair of funtions gets or sets the timezone identifier
Parse any English string representation of time and produce a time stamp:
$timestamp = strtotime($english_time);
This function can take nearly any string containing a textual description of a date and time, in English, and produce the corresponding time stamp.
Validate a date against the gregorian calendar:
$isvalid = checkdate($month,$day,$year);
Returns true if the specified date can be found on the Gregorian calendar. Useful to make sure that user input or calculated time is valid.
Find sunrise and sunset times for a given position:
$time_rise = date_sunrise($day_ts, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude);
$time_set = date_sunset($day_ts, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude);
This pair of funtions returns the time of sunrise and sunset at the specified location. The constant, SUNFUNCS_RE_TIMESTAMP, tell the function to return the time as a time stamp.
Convert a date between different calendars and Julian Day Count:
$jday_count = cal_to_jd($calendar,$month,$day,$year);
$date_array = cal_from_jd($jday_count, $calendar);
This pair functions converts a date, in a specified calendar system, to and from a Julian Day Count. These are useful for converting dates from one calendar to another. The supported calendar systems are CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH and CAL_FRENCH.
I hope you interest about my post on my site. If u like any article,please subscribe now and bookmark for me. Thanks You. We will meet again. email me at Marx Nazrin