我正在使用日历应用,需要获取每天/每月开头的时间戳等:
最好的方法是什么?
//get timestamps for start of (day, month, year)
$ts_now = time();
$ts_today =
$ts_this_month =
$ts_this_year =
答案 0 :(得分:1)
$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' ) );
我猜......
答案 1 :(得分:1)
$ts_today = strtotime('today');
$ts_this_month = strtotime("1st ".date('F')." ".idate('Y'));
$ts_this_year = strtotime( '1st january '.idate('Y') );
答案 2 :(得分:0)
手动:StrToTime