开发者

Quick help working with timestamps in php

开发者 https://www.devze.com 2022-12-27 03:39 出处:网络
I\'m working on a calendar app and need to get the timestamps for the beginning of each day/month etc:

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

精彩评论

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