How to usemicrotime() Function in PHP
The microtime() function in PHP gets the current time in seconds. We can simply multiply the resultant value by 1000 to convert the current time from seconds to milliseconds.
Example:
PHP
<?php $current_time = round (microtime(true) * 1000); echo $current_time ; ?> |
Output
1704135351653
How to Get Current Time in Milliseconds in PHP ?
In this article, we will see how to get the current time in milliseconds in PHP. There are mainly three methods to get the current time in milliseconds and they are the following:
Table of Content
- Using microtime() function
- Using DateTime class with the format method
- Using date_create() function with the format method
Contact Us