什么是PHP这一价值最快(最有效)的方法?
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 ...
什么是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 );
欢乐
你们是否希望将其修改为一种扼杀? 核对日期
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 ...
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 ...
I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?
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() ...
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 ...
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 ...
I m trying to parse timestamp strings like "Sat, 11/01/09 8:00PM EST" in Python, but I m having trouble finding a solution that will handle the abbreviated timezone. I m using dateutil s parse() ...
I love the new DATE datatype in SQL Server 2008, but when I compare a DATE field to a DATETIME field on a linked server (SQL 2005, in this case), like this: DECLARE @MyDate DATE SET @MyDate = CONVERT(...