mktime()


 

mktime()

The following example of mkdate function is used for returning Unix timestamp.

The following example of mkdate function is used for returning Unix timestamp.

PHP mktime() Function

The mktime() returns the Unix timestamp for a date that contains the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified. The arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time. If the arguments are invalid, the function returns false in PHP 5.1 version and thereafter while in earlier version, it returned -1.

Syntax

mktime(hour,minute,second,month,day,year,is_dst)

Parameter & Description of mktime() Function PHP

hour - Optional. Specifies the number of the hour.


minute - Optional. Specifies the number of the minute.


second - Optional. Specifies the second.


month - Optional. Specifies the numerical month


day - Optional. Specifies the number of the day


year - Optional. Specifies the number of year. The valid range for year is on some systems between 1901 and 2038. However this limitation is overcome in PHP 5


is_dst - Optional. Set this parameter to 1 if the time is during daylight savings time (DST), 0 if it is not, or -1 (the default) if it is unknown. If it's unknown, PHP tries to find out itself (which may cause unexpected results). Note: This parameter became deprecated in PHP 5. The new timezone handling features should be used instead.



Example of mktime() Function PHP:

The mktime() function is useful for doing date arithmetic and validation. It will automatically calculate the correct value for out-of-range input:



<?php



echo(date("M-d-Y",mktime(0,0,0,12,36,2001))."<br />");


echo(date("M-d-Y",mktime(0,0,0,14,1,2001))."<br />");


echo(date("M-d-Y",mktime(0,0,0,1,1,2001))."<br />");


echo(date("M-d-Y",mktime(0,0,0,1,1,99))."<br />");



?>

Ads