0

I have this date string for example:

10/01/14 14:00

which would be

d/m/y H:i

How can i convert it to timestamp? Considering that (/) slashes are not valid and 2 digit year is not accepted by strtodate.

Jack
  • 1,521
  • 4
  • 21
  • 29
  • 1
    Use `DateTime::createFromFormat()` to create a DateTime object. Then use `$datetime->getTimestamp()` to convert it into a timestamp. – Amal Murali Jun 16 '14 at 17:31
  • I beleave that the table with proper formats on this link should help you: http://www.php.net/manual/en/function.date.php – Jorge Campos Jun 16 '14 at 17:34
  • 1
    No problem, @Jack. It can be done with a one-liner: `echo DateTime::createFromFormat('d/m/y H:i', '10/01/14 14:00')->getTimestamp();` – Amal Murali Jun 16 '14 at 17:38

0 Answers0