-1

I currently have a date/time picker that puts the current date and time the user selected into a textbox.

The format is like the following :

22-04-2018 17:34 d-m-Y H:i

I am wondering if there is a way to convert that into a PHP timestamp?

Scotty Boy
  • 147
  • 1
  • 3
  • 9

1 Answers1

0

As I wrote in comments, the best option is to choose a "Y-m-d" format as that can easily be converted to timestamp with strtotime().
But if you can't do that you can use datetime class to convert it.

$time = "22-04-2018 17:34";
$format = "d-m-Y H:i";

$dt = date_create_from_format ($format , $time);
Echo date_timestamp_get($dt);

https://3v4l.org/eWdWN

Andreas
  • 23,610
  • 6
  • 30
  • 62