php - How can I format my timestamp right? -


i have timestamp mysql database , format it.

$date = $row['date'];  $date = date("f j, y, g:i a");  

my problem prints not date of database. instead prints out current date. not need.

so if print this, right date:

printf($row['date']); 

but if print right format not right date:

 printf($date); 

you need pass date, unix timestamp, date() second parameter. otherwise date() has no idea want format specific date:

$date = date("f j, y, g:i a", strtotime($row['date']));  

this assumes $row['date'] in valid date format.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -