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
精彩评论