-1

I am quite sure this has been discussed before but for some reason mine is not working.

I am trying to convert date time to a timestamp.

echo strtotime("18 May 2.50pm");

The above code returns blank.

Any help is highly appreciated. Thanks in advance.

Prithviraj Mitra
  • 11,002
  • 13
  • 58
  • 99

1 Answers1

0

Use php DateTime::createFromFormat to make DateTime

<?php
$date = DateTime::createFromFormat('j M h.ia', '18 May 2.50pm');
echo $date->getTimestamp();
//print_r($date);
?>

Live Demo

Now you can use method available for DateTime .

Note : As you have not given year it will give you result for current year

Niklesh Raut
  • 34,013
  • 16
  • 75
  • 109