Milliseconds since when? You can get the value as an Unix timestamp using now()->timestamp
Jul 6, 2020
5
Level 6
Is there a way to convert a full date to milliseconds?
Is there a way to convert a now() to milliseconds?
Level 104
Use microtime(true) instead of now() to get the timestamp in milliseconds.
No., this returns in seconds with milliseconds (as a decimal value). With both solutions given above, the OP would need times 1000 the value returned because they both return seconds
$millisecondsSinceEpoch = microtime(true) * 1000
Edit @chron Carbon has a getPreciseTimestamp method which takes a precision argument (3 give millisecond precision):
$numMilisecondsSinceEpoch = Carbon::parse('2020-07-06 20:17:28.900295')->getPreciseTimestamp(3);
Please or to participate in this conversation.