Add to collection
Md Riyazuddin

Md Riyazuddin

Verified

How to get AM/PM from a datetime in PHP

You need to convert it to a UNIX timestamp using strtotime and then back into the format and also you require to use the date function.



                                              
$currentDateTime = '08/04/2010 22:15:00';
$newDateTime = date('h:i A', strtotime($currentDateTime));
echo $newDateTime;
Tagged with: PHP

Comments 0

  • Sorry!! No comment posted yet. Become the first user to give comment.
Add a comment

Would you like to write for w3 sniff?

Become part of an amazing group of contributors and authors and start writing for us

Join Now
$currentDateTime = '08/04/2010 22:15:00';
$newDateTime = date('h:i A', strtotime($currentDateTime));
echo $newDateTime;
Feedback submitted successfully.