I need to get 2020-04-24T10:17 in this format 2020-04-24 10:17:00:000 for inserting into MSSQL datetime field.
This is what I’ve tried:
echo date("Y-m-d H:i:s:u", strtotime($dateTime));
$dateTime
contains 2020-04-24T10:17 but the above code returns 1969-12-31 19:00:00:000000.
Advertisement
Answer
It works for me. Make sure that $dateTime has the actual time.
Tested on php 7.0
$dateTime = "2020-04-24T10:17"; echo date("Y-m-d H:i:s:u", strtotime($dateTime));