PHP中的FormatDateTime [英] FormatDateTime in PHP

查看:63
本文介绍了PHP中的FormatDateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近做了一份PHP工作,但是来自ASP背景。我是

试图找到VBScript''formatdatetime"的转换等价物。


我想做的就是转换MySQL日期时间进入一个漫长的日期。

例如2006-01-30至2006年1月1日。

请提供一个我可以用作未来基准的示例,以便我能够更好地理解语法。我真的需要学习PHP,而且我现在很难被吓到了。

谢谢!

解决方案

John K写道:

我最近做了一份PHP工作但是来自ASP背景。我正在尝试找到VBScript''formatdatetime'的转换等价物。

我想要做的就是将MySQL日期时间字段转换为长日期。
例如2006-01-30至2006年1月1日。

请提供一个我可以用作未来基准的示例,以便我能更好地理解语法。我真的需要学习PHP,而且我现在很害怕。

谢谢!




2006-01 -30可以转换为2006年1月1日。使用

date(F j,Y,mktime(0,0,0,01,30,2006));

或者,你可以完成同样的事情变量插入mktime的任务

函数:

date(" F j,Y",mktime(


hour,

分钟,

I recently took a job doing PHP but come from an ASP background. I''m
trying to find a conversion equivalent for VBScript''s "formatdatetime".

All I want to do is convert a MySQL datetime field into a long date.
e.g. 2006-01-30 to January 1, 2006.
PLEASE provide an example that I can use as a future benchmark so I can

understand the syntax better. I really need to learn PHP and I''m a
little freaked out right now.
Thanks!

解决方案

John K wrote:

I recently took a job doing PHP but come from an ASP background. I''m
trying to find a conversion equivalent for VBScript''s "formatdatetime".

All I want to do is convert a MySQL datetime field into a long date.
e.g. 2006-01-30 to January 1, 2006.
PLEASE provide an example that I can use as a future benchmark so I can

understand the syntax better. I really need to learn PHP and I''m a
little freaked out right now.
Thanks!



2006-01-30 can be converted to "January 1, 2006" using
date("F j, Y",mktime(0,0,0,01,30,2006));
Or, you can accomplish the same task with variables stuck into the mktime
function:
date("F j, Y",mktime(


hour,


minute,


这篇关于PHP中的FormatDateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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