Copyright © tutorialspoint.com

PHP Function mktime()

previous
Advertisements

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
hour Optional. Specifies the hour
minute Optional. Specifies the minute
second Optional. Specifies the second
month Optional. Specifies the numerical month
day Optional. Specifies the day
year Optional. Specifies the year.
is_dst Optional. 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
previous

Copyright © tutorialspoint.com