PHP data, time function Avenue to Jane Date/time functions allow you to extract and format dates and times on the server. Runtime configuration
PHP date/time functions 1, checkdate ()
The Checkdate () function validates a trellis-high-date.
If the specified value is valid, the function returns True, otherwise false is returned.
The date is valid in the following cases:
Month is between and includes 1-12
The value of day is within the range of days that a given month should have, and leap years are taken into account.
Year is between and includes 1 to 32767
Example
<?phpvardump (Checkdate (12,31,2000)); Vardump (Checkdate (2,29,2003)); Var_dump (Checkdate (2,29,2004)); >
Output:
BOOL (TRUE) bool (FALSE) bool (true)
2. Date
defaultTimezone_get ()
Example
<?phpecho (Datedefaulttimezone_get ());? >
Output:
PRC
3. Date
defaultTimezone_set ()
Thedate default timezone set() function sets the time zone used in the script for all date/time functions.
Example
<?php Echo (Datedefaulttimezoneset ("Europe/paris"));? >
Output:
1
List of legitimate time zones: http://www.php.net/manual/en/timezones.php
4. Date_sunrise () function
The dateSunrise () function returns the sunrise time for the specified date and place.
Datesunrise (Timestamp,format,latitude,longitude,zenith,gmt_offset)
Example
<?php//calculates sunrise time in Lisbon, Portugal//latitude: Latitude 38.4 degrees//longitude: Longitude 9 degrees West//zenith ~= 90//offset: +1 gmtecho ("Date:". Date ("D M D Y"). Echo ("Sunrise Time:"), Echo (Datesunrise (Time (), sunfuncsret_string,38.4,-9,90,1)); >
Output:
Date:tue Jan 2006Sunrise time:08:52
5. Date_sunset () function
Ditto
6. Date () function
The date () function formats a local time/date
Data (return format, timestamp);
Example
<?php Echo ("Result with date ():"); Echo (Date ("L")); Echo (Date ("L DS \of F Y h:i:s A")); Echo ("Oct 3,1975 is on a". Date ("L", Mktime (0,0,0,10,3,1975))); Echo (Date (date_rfc822)); Echo (Date (Date_atom,mktime (0,0,0,10,3,1975))); Echo ("Result with Gmdate ():"); Echo (Gmdate ("L")); Echo (Gmdate ("L DS \of F Y h:i:s A")); Echo ("Oct 3,1975 is on a". Gmdate ("L", Mktime (0,0,0,10,3,1975))); Echo (Gmdate (date_rfc822)); Echo (Gmdate (Date_atom,mktime (0,0,0,10,3,1975))); ? >
Output:
Result with date (): Tuesday Tuesday 24th of January 2006 02:41:22 PM Oct 3,1975 is on a Friday Tue, 2 4 Jan 2006 14:41:22 CET 1975-10-03t00:00:00+0100 Result with Gmdate (): Tuesday Tuesday 24th of January 2006 01:41:22 PM Oct 3,1975 is on a Thursday Tue, Jan 2006 13:41:22 GMT 1975-10-02t23:00:00+000 0
Note: the Mktime () function returns a Unix timestamp for a date. 7. GETDATE () function
The GETDATE () function obtains the date/time information.
8. Gettimeofday () function
The Gettimeofday () function returns an array containing the current time information.
Subtotal, all functions
PHP Data, Time function