How to get current time in milliseconds in php?

In this article, we helps you get current time in milliseconds in php.

1. Code:

<?php 
	
	function getCurrentTimeInMilliseconds (){
		$mt = explode(' ', microtime());
		return ((int)$mt[1]) * 1000 + ((int)round($mt[0] * 1000));
	}
	
	echo getCurrentTimeInMilliseconds();
    ?> 

2. Example:

Input:

getCurrentTimeInMilliseconds();

Output:

1660125238122