-1
我必须从数字字符串外推一个仅由月和年组成的日期。 E.g: 像这样的字符串:从数字字符串到PHP中的int数组
201611
有可能成为:
2016-11
以后,我保存这个日期在DB的FILD这是一个日期时间。 你能帮我吗? 谢谢!
我必须从数字字符串外推一个仅由月和年组成的日期。 E.g: 像这样的字符串:从数字字符串到PHP中的int数组
201611
有可能成为:
2016-11
以后,我保存这个日期在DB的FILD这是一个日期时间。 你能帮我吗? 谢谢!
$new_date = substr_replace($old_date, '-', 4, 0);
见http://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php –
感谢的,但是,这样一来,像这样的 '201412' 的字符串成为'2014-41' – luca
对不起,'$ newdate = substr($ oldDate,0,4)。 “ - ”。 substr($ oldDate,4,2);' – Phiter