0

I tried using strtotime() to convert a string to a date, but apparently it can't handle milliseconds/microseconds or the meridian.

This returns false:

$date = strtotime('30-APR-13 01.31.50.584000000 PM');

How can I convert the above to a date?

neuquen
  • 3,991
  • 15
  • 58
  • 78
  • timestamps in php are "**Seconds** since 01-01-1970 00:00:00". Meaning they wouldn't include sub-second precision. If you needed more precision, you would likely want to use the DateTime class. – Jonathan Kuhn Nov 02 '15 at 21:06
  • createFromFormat with the `u` format but you'll lose the last 3 digits of the microseconds. – AbraCadaver Nov 02 '15 at 21:14
  • The linked question did have the answer. I ended up using `DateTime::createFromFormat('d-M-y h.i.s.u A', '30-APR-13 01.31.50.584000000 PM');` to get what I needed. – neuquen Nov 02 '15 at 21:20

0 Answers0