I think this organisation will be one of the big players of the future in the PHP world. 我认为,这个组织将在PHP世界的未来的大牌球员之一。”
达伦

日期和时间

日期和时间

一旦你开始做更复杂的脚本,你会很快需要开始使用的日期和时间。 例如,也许你想记录,当有人在数据库中注册,或显示不同的图像,在一年的时间而定? 当使用时间,这是很好的做法,首先你要使用的时区设置。
" GMT " ) ; date_default_timezone_set(“GMT”);
然后,您可以使用日期的功能,以获得所需的最新信息。 日期函数输出的基础上,到函数输入日期字符串的格式字符串。
date ( " h " ) ; 回声日期(“H”);
outputs the current hour as a number from 01 - 12 / /输出数量从01小时- 12
date ( " H " ) ; 回声日期 “H”);
outputs the Month from Jan to Dec / /输出1月至12月每月
date ( " d " ) ; 回声日期(“D”);
outputs the current hour as a number from 01 - 23 / /输出数量从01小时- 23
date ( " D " ) ; 回声日期(“D” );
outputs the day from Mon to Sun / /输出从周一至周日的一天
date ( " m " ) ; 回声日期(“M”);
outputs the current month as a number from 01 - 12 / /输出数量从01个月- 12
date ( " M " ) ; 回声日期 “M”);
outputs the Month from Jan to Dec / /输出1月至12月每月
date ( " y " ) ; 回声日期(“Y”);
outputs the current year as a two digit number / /输出本年度两位数字
date ( " Y " ) ; 回声日期(“Y” );
outputs the current year as a four digit number / /输出本年度作为一个四位数字
这些字符串格式当然可以相结合,使更复杂的数字。 也有大量更多的格式选项,请参阅更多的PHP网站。
date ( " d - m - y " ) ; 回声日期(“D - M - Y”);
outputs the current year so 05 - 12 - 2008 / /输出电流的一年,所以05 - 12 - 2008
因此,这可以用来像这样
date ( " m " ) = = 12 ) 如果(日期(“M”)== 12)
{
show christmas logo / /显示圣诞节标志
}
其他
{
show normal logo / /显示正常的标志
}
在日期函数有两个参数,第一个是字符串函数,第二个是时间戳,它应立足之日起。 现在时间默认,但未来或过去的时间戳可以用来操纵未来的或过去的日期。 因此使用时间的功能,我们将有一天回去。 注意时间的函数输出当前的时间戳记。
timestamp = time ( ) ; $时间戳=();
timestamp = $ timestamp - ( 24 * 60 * 60 ) ; $时间戳= $时间戳- (24 * 60 * 60);
minus 24 hours * 60 minutes * 60 seconds / /减去24小时* 60分钟* 60
as the timestamp is minutes since January 1 1970 00 : 00 : 00 GMT / /时间戳分钟1970年00:00:00时间自11日起
date ( " d - m - y " , $ timestamp ) ; 回声日期(“D - M - Y”,$ timestamp)的;
outputs the current year so 04 - 12 - 2008 , when the current date is the 05 - 12 - 2008 for instance . / /输出,所以04 - 12 - 2008年 当目前的日期是05 - 12 - 2008 例如当年

已提供任何意见。
安全形象
书面由多米尼克·斯金纳
最后更新:2011年10月25日十六点00分38秒