Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php time() vs mktime() for current timestamp

Tags:

php

time

mktime

Are there any differences between using functions time() and mktime() with default parameters to obtain current timestamp?

like image 859
Sergey Terehin Avatar asked Mar 28 '13 13:03

Sergey Terehin


People also ask

What is the purpose of Mktime () function?

The mktime() function returns the Unix timestamp for a date. 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.

What does time () do in PHP?

The time() function returns the current time in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

How does Mktime work in PHP?

The mktime() function is an inbuilt function in PHP which is used to return the Unix timestamp for a date. The timestamp returns a long integer containing the number of seconds between the Unix Epoch (January 1, 1970, 00:00:00 GMT) and the time specified.


1 Answers

"As of PHP 5.1, when called with no arguments, mktime() throws an E_STRICT notice: use the time() function instead."

http://php.net/manual/en/function.mktime.php

If you want to use dates/times, I recommend DateTime instead.

like image 87
Anyone Avatar answered Nov 09 '22 01:11

Anyone