PHP - Function mktime()


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.

Parameters

Sr.No Parameter & Description
1

hour

Optional. Specifies the hour

2

minute

Optional. Specifies the minute

3

second

Optional. Specifies the second

4

month

Optional. Specifies the numerical month

5

day

Optional. Specifies the day

6

year

Optional. Specifies the year.

7

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 the following result −

Last day in Feb 2000 is: 29 

php_function_reference.htm

Advertisements