开发者

date() or format_date() returning 1970?

开发者 https://www.devze.com 2023-03-06 10:08 出处:网络
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开发

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.


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 )); ?>
0

精彩评论

暂无评论...
验证码 换一张
取 消