首頁 美術繪圖 | 美術設計 | 熱門標籤 | 首選 | 首頁宣傳 | 近期作品 論壇: 發表 | 美術工作 | 美術比賽 | 展覽活動 | 美術相關 | 一般討論 | 美術同好 CG 討論 :: Photoshop | Painter | 3D 行動 | AMP

【 立即註冊 】 : 更改個人資料 : : 登入

會員名稱: 登入密碼: 保持登入

上個月完整 UNIXTIME 範圍: mktime, time, date, strtotime PHP Example

發表新主題 回覆主題 討論區 Windows, Linux, Perl, PHP, C/C++, Driver, Web 理論、應用、硬體、軟體

| 1頁, 共1
人氣點閱:4131 發表人
上個月完整 UNIXTIME 範圍: mktime, time, date, strtotime PHP Example 2014-10-07 15:01
/ / /

Last Month EPOCH time coverage 上個月完整的 UNIX TIME 範圍 (PHP)




PHP Code Examples which count unixtime of
first day of last month (00:00:00) to last day of last month (23:59:59)

e.g. 2014/12/01 00:00:00 ~ 2014/12/31 23:59:59

代碼:


/* (a): Count timestamp diff from 00:00:00 ~ now */
/* (a): 今天 00:00:00 ~ 目前的 UNIX timestamp */

$gap_epoch = time() - mktime('00', '00', '00', date('n', time()), date('j', time()), date('Y', time()));
echo $gap_epoch;

/* (b) First Day of Last Month 00:00:00, e.g. 2014-12-31 00:00:00 */
/* (b) 上個月「第一天」的 00:00:00 */

$unixtime_last_month_begin = strtotime('first day of last month') - $gap_epoch;
echo date('Y-m-d H:i:s', $unixtime_last_month_begin);

/* (c) Last Day of Last Month 00:00:00  e.g. 2014-12-31 23:59:59 */
/* (c) 上個月「最後一天」的 23:59:59 */

$unixtime_last_month_end   = strtotime('last day of last month') - $gap_epoch + 86400 - 1;
echo date('Y-m-d H:i:s', $unixtime_last_month_end);

/* (d) Convert to UNIX TIME again from String  */
echo strtotime(date('Y-m-d H:i:s', $unixtime_last_month_begin));
echo strtotime(date('Y-m-d H:i:s', $unixtime_last_month_end));





service



繪圖畫廊設計藝廊
攝影相簿留言板
最愛收藏分類標籤
暱稱: staff
註冊: 2007-03-30
發表: 48

V幣: 2703





資訊相關理論、技術、管理、應用、產品等
發表新主題 回覆主題