EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
设置为默认语言
PF 问题 - 论坛

将日期从一种格式转换为另一个 PHP 中

有没有简单的办法,将日期的格式转换为另一种日期格式在 PHP 中?

我有这:

我到底做错了?

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
彼得枯病 preguntó 我们的一日三餐 7 年
1 答案
最佳答案

第二个参数传递给你 日期() 必须是合适的参数, 即, 以来的秒数 1 在 1 月的 1970. 你通过它的字符串不承认它.

它使用 strtotime() 要转换的日期字符串 时间戳, 尽管不 strtotime() 将识别 y-m-d-h-i-s.

PHP 5.3 以下简称

使用 DateTime::createFromFormat. 允许您指定精确的蒙版,使用的语法 日期() 分析传入日期.

PHP 5.2 和以前

你要扫描的项目 (一年, 个月, 一天, 时间, 分钟, 第二次) 使用 substr() 并通过对结果 mktime () 打造一个时间戳.

大量的工作! 我推荐使用的格式不同 strtotime() 你需要知道. 试试这个:

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
编码器 说的得 7 年