Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

date() or format_date() returning 1970?

Tags:

date

php

I have a table with a date field, which is correctly populated.
When I do the following <?php print $mytable->date; ?> works fine; however, when I format it with date() or format_date() it just returns 01/01/1970.

It's stored in an array before being put into an HTML table if that makes a difference.

like image 576
Mythical Fish Avatar asked Jan 20 '23 18:01

Mythical Fish


1 Answers

You could use the following (if the format of $mytable->date fits strtotime()) and adopt first parameter to your needs:

<?php echo date('Y-m-d H:i:s', strtotime( $mytable->date )); ?>
like image 90
AndersTornkvist Avatar answered Jan 30 '23 23:01

AndersTornkvist