convert unix timestamp php

99封情书 提交于 2019-12-01 07:36:47

You can use the strtotime and date function:

echo date('Ymdhis', strtotime($date));

Use date.

$date = date("YmdHis", $timestamp);

here you go

print date("YmdHis",unixtimestamp);

If you're using mysql, it has a DATE_FORMAT function. You can call it like

SELECT DATE_FORMAT(`datefield`, "%Y%m%d%H%i%s") AS `date_formatted` FROM table;

So you get an already formatted date from your database.

Use the right format :

date('YmdHis');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!