PHP mktime() Function

6 Jan 2025 | 1 min read

The PHP mktime() function is used to find the day of that particular date. It returns the Unix timestamp for a date.

Syntax

Parameters

ParameterDescriptionRequired/Optional
HourSpecifies the houroptional
MinuteSpecifies the minuteoptional
SecondSpecifies the secondoptional
MonthSpecifies the monthoptional
DaySpecifies the dayoptional
YearSpecifies the yearoptional
Is_dstSet this parameter to 1 as DSToptional

Return

The mktime() function returns the Unix timestamp of the arguments given. This function returns FALSE, if the arguments are invalid.

Example 1

Output:

 Aug 6, 2018 was on a Monday. 

Example 2

Output:

 Jan-05-2002 Feb-01-2002 Jan-01-2001 Jan-01-1999 

Example 3

Output:

 Last day in Feb 2000 is: 29 Last day in Feb 2000 is: 29