PHP time and Other Related Functions

In PHP, the time() function is used to display the current Unix timestamp in milliseconds. Of course, a whole lot more can be achieved with this and other related functions. You can use the time function to find out the unix timestamp. This can later be formatted using the date() function.


If you need to display the Unix time in milliseconds, use the microseconds() function instead.


Note: microtime() displays the microseconds in decimals along with the regular Unix Epoch time.


This function is used to find the Unix time for a particular day/hour/minute/second. You use the function as mktime(hour, minute, second, month, day, year).


Note: The example shows the use of mktime to find out the epoch date for a particular day created by mktime. The epoch day is calculated as 1414164030. The same epoch date has been manually entered to be formatted using date() function.


A pretty useful function for parsing human readable textual dates into Unix timestamp. This one simplifies finding the epoch date for certain days.

For example:

Note: You can use the date function to format these timestamps after this.

You may also like

Comments are closed here.


Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 2 other subscribers