PHP date and time related functions

PHP date and time
1. Verification date.
    Checkdate() returns TRUE if the supplied date is valid, otherwise returns FALSE.
    Bool bheckdate(int month, int day, int year);
2. Format the date.
    The date() function returns the string form of the time and date formatted by the instruction according to the predefined format.
    String date(string format [, int timestamp]);
    Date("F d, Y"); August 22,2007
    Date("l"); Monday
    Date("mdY"); 07-15-2010
3. Learn more about the current time. (???)
    The gettimeofday() function returns an associative array of elements related to the current time.
    Mixed gettimeofday([bool return_float);
    Returns Array([sec],[usec],[minuteswest],[dsttime])

4. Convert the timestamp to a user-friendly value.
    Array getdate([int timestamp]);
    Returns Array([hours],[mday],[minutes],[mon],[month],[seconds],[wday],[weekday],[wday],[weekday],[yday],[year] , [0]);
5. Determine the current timestamp.
    Int time();
6. Create a timestamp based on a specific date and time.
    Int mktime([int hour [,int minute [,int second [,int month [,int day [,int year [,int is_dst]]]]]]);

Date function.
Displays the date and time of localization.
7. Set the default localization environment. (???)
    String setlocale(mixed category,string locale [,string locale...]);
    String setlocale(mixed category,array locale);
The 8.strftime() function formats the date and time according to the localization settings made by setlocale().
    String strftime(string format [, int timestamp]);
9. Display the latest modification date of the web page.
    Int getlastmod();
10. Determine the number of days in the current month.
    Use the t parameter of date().
    Date("t");
11. Determine the number of days in a given month.
    Mktime() works with date().
    $lastday = mktime(0,0,0,3,0,2007);
    Echo date("t",$lastday);
12. Calculate the date after x (days) after the current date.
    The strtotime() function and the GNU date syntax (???), plus a minus sign indicate the first x days.
    $futuredate = dtrtotime("45 days");
    Echo date("F d, Y",$futuredate);

Leave a Comment

error: Content is protected !!