PHP函数获取日期格式? [英] PHP function to get the date format?

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

问题描述

我知道如何使用日期格式字符串,将 date('Y / m / d H:i:s'); 转换为 2009/12/18 11:37:45

I know how to use date format strings, to turn date('Y/m/d H:i:s'); into 2009/12/18 11:37:45.

我想要一个可以做相反的功能,看看格式化的日期返回格式。在PHP中有一个吗?

I would like a function that can do the opposite - look at a formatted date then return the format. Is there one in PHP?

原因是我们以各种格式保存在数据库中的时间戳,我正在编写一个处理所有旧表和分析的工具日期条目。

The reason is we have timestamps saved in our database in a variety of formats and I am writing a tool processing all of our old tables and analyzing the date entries.

编辑:所以我想没有一个直接的方法来做到这一点。我在想我可以使用strftime(),它返回从时代开始的秒数。那么一个更好的问题是我可以在几秒钟内在mySQL数据库的时间戳记字段中使用那个时间吗?如果表格被构造为时间戳而不是varchar,那么这可能会起作用,这有时是。

so I guess there isn't a straight-forward way to do this. I was thinking I could use strftime(), which returns the time in seconds since the epoch. So a better question is can I use that time in seconds in the timestamp fields in the mySQL database? I would guess this would work if the table is structured as a timestamp and not a varchar,which is sometimes is.

推荐答案

查看 strptime()

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

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