Monday, 26 August 2013

PHP Function mktime()

Syntax

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

Definition and Usage

This function returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer containing the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.
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.

Paramters

ParameterDescription
hourOptional. Specifies the hour
minuteOptional. Specifies the minute
secondOptional. Specifies the second
monthOptional. Specifies the numerical month
dayOptional. Specifies the day
yearOptional. Specifies the year.
is_dstOptional. Parameters always represent a GMT date so is_dst doesn't influence the result.

Return Value

This function returns the Unix timestamp of the arguments given. If the arguments are invalid, the function returns FALSE.

Example

Following is the usage of this function:
<?php
$lastday = mktime(0, 0, 0, 3, 0, 2000);
echo strftime("Last day in Feb 2000 is: %d\n", $lastday);
$lastday = mktime(0, 0, 0, 4, -31, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
?>
This will produce following result:
Last day in Feb 2000 is: 29 

Last day in Feb 2000 is: 29

No comments:

Post a Comment