【发布时间】:2011-10-20 00:03:56
【问题描述】:
如何转换这个字符串
$parent = "2011-08-04 15:00:01";
把它分成两个字符串:
$child1= "2011-08-04";
$child2 = "12:00:01";
然后转换
$child1 to this format 8.4.2011
和
$child2 to this format 15:00
【问题讨论】:
如何转换这个字符串
$parent = "2011-08-04 15:00:01";
把它分成两个字符串:
$child1= "2011-08-04";
$child2 = "12:00:01";
然后转换
$child1 to this format 8.4.2011
和
$child2 to this format 15:00
【问题讨论】:
$parent = '2011-08-04 15:00:01';
$timestamp = strtotime($parent);
$child1 = date('n.j.Y', $timestamp); // d.m.YYYY
$child2 = date('H:i', $timestamp); // HH:ss
【讨论】:
$time = new DateTime("2011-08-04 15:00:01");
$date = $time->format('n.j.Y');
$time = $time->format('H:i');
【讨论】:
date('Y-m-d', strtotime( '2015-04-16 15:00:01' ) );
这将为您提供正确的日期格式,然后是 mysql 即 2015-04-16 03:54:17
【讨论】: