Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format date from database?

Tags:

date

php

format

When I pull the date out of the db, it comes back like this:

2009-10-14T19:00:00

I want to format it in two different ways...

The first: F d, Y The second h:m (12 hour format)

Everything I try returns December 1969... Help?! I feel so confused...

like image 488
n00b0101 Avatar asked Sep 10 '25 16:09

n00b0101


2 Answers

Normally the code is just:

echo date('F d, Y h:mA', strtotime('2009-10-14 19:00:00'));

Note that if strtotime() can't figure out the date, it returns the time as 1/1/1970 00:00:00 GMT.

like image 125
too much php Avatar answered Sep 12 '25 09:09

too much php


Simple date display function :

 echo date('m-d-Y H:i:s',strtotime($date_variable));
like image 42
Gaurav Gupta Avatar answered Sep 12 '25 09:09

Gaurav Gupta