在PHP中更改日期的格式 [英] Change the format of a Date in PHP

查看:58
本文介绍了在PHP中更改日期的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有以下代码:


I have this code :


$timestamp_bad = strtotime($statuses[$i]['created_at']);
$timestamp = strptime(strftime("%Y-%m-%d %T", $timestamp_bad), "%Y-%m-%d %T");
echo $timestamp;

我想更改日期($ statuses [$ i] ['created_at'])例如 Sat Dec 04 17:43:38 +0000 2010 放入例如 2010-12-05 10:00:26 ,但是如果我运行粘贴的代码,则返回 Array()

如何更改该日期的格式?

I want to change a date ($statuses[$i]['created_at']) which is for example "Sat Dec 04 17:43:38 +0000 2010" into for example 2010-12-05 10:00:26, but if I run the code I pasted you, in returns Array ( )
How can I change the format of that date?

推荐答案

具有日期功能:

$myDate = date('Y-m-d h:i:s', $timestamp);

这篇关于在PHP中更改日期的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆