English 中文(简体)
时间明确——今天就在中午12:00时。
原标题:time() with clearTime - just today at 12:00 AM

什么是PHP这一价值最快(最有效)的方法?

最佳回答

http://fr2.php.net/strtotime"rel=“nofollow”strtotime()

$today = strtotime( 00:00:00 );

var_dump($today);
var_dump(date( Y-m-d H:i:s , $today));

And you d get the following output :

int 1301436000
string  2011-03-30 00:00:00  (length=19)


Or, using the DateTime class :

$dt = new DateTime( 00:00:00 );

var_dump($dt->format( U ));
var_dump($dt->format( Y-m-d H:i:s ));

得出这一产出:

string  1301436000  (length=10)
string  2011-03-30 00:00:00  (length=19)
问题回答

最短的编码转换将是

$midnight = strtotime("today midnight");

就效率而言,你必须制定基准。 时间是顶峰下的巨大堡垒,虽然该法典是紧凑的,但内部可以有数千条法典,以达到与时标相同的几条法典。

在您使用<代码>strtotime()之前,确保服务器的PHP config有正确的时间区。

测试

echo date_default_timezone_get();

如果你在其他国家使用当地托管(有时是)或服务器,这可能是问题。 时间范围并不观测时间区,但职能strtotime()肯定会!

如有必要,使用<代码>strtotime()、date(>或类似内容的代码上设定时间。

date_default_timezone_set( America/New_York );

欢乐

你们是否希望将其修改为一种扼杀? 核对日期

http://php.net/manual/en/function.date.php





相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签