将php4 date()转换为php5 date_format() [英] Converting php4 date() to php5 date_format()

查看:92
本文介绍了将php4 date()转换为php5 date_format()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

$date = mktime(12, 0, 0, $month, 1, $year); // 1st day of month as unix stamp
for( $day = 1; $day <= date("t", $date); $day++ ) {
     //...
}

执行时,会产生以下通知:

When executed it produces the following notice:


注意:
/home2/wordprh4/public_html/contenido/themes/bam/events/table-mini.php
中遇到的非格式数值在线53

Notice: A non well formed numeric value encountered in /home2/wordprh4/public_html/contenido/themes/bam/events/table-mini.php on line 53

我想使用php5转换 date(); date_format(),但我有一些问题...

I would like to convert date(); using php5 date_format() but I'm having some issues...

这是什么正确的方法?

FYI line 53 is

FYI line 53 is

for( $day = 1; $day <= date("t", $date); $day++ ) {


推荐答案

我看不到需要这样做,但你可以使用这样的date_format()

I dont see a need to do this, but You can use date_format() like this

$date = date_create('2012-02-01'); //First you have to create the date
echo date_format($date, 'Y-m-d H:i:s'); //Next simply pass the needed format

这篇关于将php4 date()转换为php5 date_format()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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