如何在 PHP 中解析日期字符串? [英] How to parse a date string in PHP?

查看:33
本文介绍了如何在 PHP 中解析日期字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

日期字符串为Apr 30, 2010,如何使用PHP将字符串解析为2010-04-30?

With a date string of Apr 30, 2010, how can I parse the string into 2010-04-30 using PHP?

推荐答案

尝试 http://php.net/manual/en/function.strtotime.php 转换为时间戳,然后 http://www.php.net/manual/en/function.date.php 以您自己的格式获取它.

Try http://php.net/manual/en/function.strtotime.php to convert to a timestamp and then http://www.php.net/manual/en/function.date.php to get it in your own format.

这篇关于如何在 PHP 中解析日期字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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