Tags
Asked 3 years ago
13 Jul 2021
Views 182
Brionna

Brionna posted

What is Mktime PHP ?

What is Mktime PHP ?
noob

noob
answered Oct 8 '21 00:00

mktime() is the function in PHP which returns Unix timestamp for a date.
mktime() is used for converting date to timestamp which can be used as argument another function like date() function .

what is the syntax of the mktime() ?

one need to pass the hour, minute, second, day, month, and year separately to the mktime() function.


mktime(
    int $hour,
    int $minute = null,
    int $second = null,
    int $month = null,
    int $day = null,
    int $year = null
)

mktime() return the integer timestamp if all argument passed is valid
mktime() return false if something went wrong.

how to use mktime() function with date() function ?

convert date to time by mktime() and pass in the date() function.

date('Y-m-d',mktime(0,0,0,11,10,2021))

it will print 2021-10-11
Post Answer