Search code examples
phpdatetimedatetime-formatunix-timestamp

How Do I convert datetime-local input to unix timestamp?


I am working with an input which type is datetime-local. I need to convert this to unix timestamp.

here's an example of what format the raw value submitted is 2018-06-12T19:30.

I need to convert dates in formats such as the above into this format 1608954764, the current unix timestamp.


Solution

  • strtotime() will return a Unix epoch for the time given.

    <?php
    strtotime("2018-06-12T19:30");
    ?>