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)

It specifies the hour

2

minute(Optional)

It specifies the minute

3

second(Optional)

It specifies the second

4

month(Optional)

It specifies the numerical month

5

day(Optional)

It specifies the day

6

year(Optional)

.It specifies the year.

7

is_dst(Optional)

It prameters 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, 2010);
   echo strftime("Last day in Feb 2010 is: %dn", $lastday);
   
   $lastday = mktime(0, 0, 0, 4, -31, 2010);
   echo strftime("Last day in Feb 2010 is: %d", $lastday);
?>

This will produce the following result −

Last day in Feb 2010 is: 28nLast day in Feb 2010 is: 28

php_function_reference.htm

Advertisements