开发者

Quick help working with timestamps in php

I'm working on a calendar app and need to get the timestamps for the beginning of each day/month etc:

whats the best method?

//get timestamps for start of (day, month, year)
$ts_now         = time();
$ts_today      = 
$ts_this_month  =
$t开发者_开发技巧s_this_year   =


$ts_today       = mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) );
$ts_this_month  = mktime( 0, 0, 0, date( 'm' ), 0, date( 'Y' ) );
$ts_this_year   = mktime( 0, 0, 0, 0, 0, date( 'Y' ) );

I guess...


$ts_today = strtotime('today');
$ts_this_month = strtotime("1st ".date('F')." ".idate('Y'));
$ts_this_year = strtotime( '1st january '.idate('Y') );


Manual: StrToTime

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜