List of timestamp function available in PHP

When I was working in date and time type of module, I came to know about the timestamp format.  But on that time I used strtime and mktime function from PHP.

After that I was analysing about timestamp in PHP, below are the timestamp function available in PHP. So I want to share the function for timestamp.

Most of us not use all the function to get unix timestamp, each one is having its own feature to display timestamp.

strtotime : this function display unix timestamp from number of seconds since January 1 1970 00:00:00 UTC, for the timestamp given in now.

<?php
echo strtotime("now");

mktime : return unix timestamp for the given date and time, between number of seconds since January 1 1970 00:00:00 UTC.  Need to pass arguments for hour, minutes, seconds, month, day and year.

<?php
echo mktime(date("H"),date("i"),date("s"),date("n"),date("j"),date("Y"));

gmmktime : It’s same like mktime function, but display in GMT date.

<?php
echo gmmktime(date("H"),date("i"),date("s"),date("n"),date("j"),date("Y"));

microtime : return the unix timestamp with microseconds, it’s support when gettimeofday function is enabled. if it’s true it will return as float or else string.

<?php
echo microtime(true);

gettimeofday :  return current time in array format, if it’s true it will return float.

<?php
echo gettimeofday(true);

time : return current timestamp since January 1 1970 00:00:00 GMT.

<?php
echo time();
Share