开发者

How i can use the SQLDATE in codeigniter php?

Can you explain below line? pl开发者_运维问答s give some example.

strtotime(SQLDATE." +1 month")


This is not specific to CodeIgniter, it's a generic PHP function:

From the docs:

The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC)

Also, regarding the relative date/time format:

Format: number space? (unit | 'week')
Handles relative time items where the value is a number.
Example: "+5 weeks", "12 day", "-7 weekdays"

So your example:

SQLDATE = '2011-10-28';
strtotime(SQLDATE. "+1 month");

will return the Unix timestamp for the date 1 month after the 28th October 2011.


Simply put you are just adding 1 month to the value of the date in SQLDATE. So in your example, the value that strtotime will return is 1 month after 2011-10-28 which is 2011-11-28.

Strtotime returns the number of seconds since the epoch. The return values of strtotime will make more sense if you format it:

php > define("SQLDATE",'2011-10-28');
php > echo date("Y-m-d",strtotime(SQLDATE));
2011-10-28
php > echo date("Y-m-d",strtotime(SQLDATE . "+1 month"));
2011-11-28
php > 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜