日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

每天的0点php,使用strtotime,这个月的第一天凌晨0点在PHP?(Using just strtotime, 0 am first day of this month in PHP?)...

發布時間:2023/12/4 php 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 每天的0点php,使用strtotime,这个月的第一天凌晨0点在PHP?(Using just strtotime, 0 am first day of this month in PHP?)... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用strtotime,這個月的第一天凌晨0點在PHP?(Using just strtotime, 0 am first day of this month in PHP?)

echo mydate(strtotime('1 am first day of this month'));

以上工作結果2017-10-01 01:00:00 ,但我很難在凌晨0點做到。 24am, 24pm, 0pm, first second工作。

echo mydate(strtotime('1 am first day of this month'));

Above works with result 2017-10-01 01:00:00, but I have difficulty to do it for 0 am. Neither 24am, 24pm, 0pm, first second works.

原文:https://stackoverflow.com/questions/46974127

更新時間:2019-12-08 15:31

最滿意答案

使用midnight :

echo mydate(strtotime('midnight first day of this month'));

Use midnight:

echo mydate(strtotime('midnight first day of this month'));

2017-10-27

相關問答

你應該使用mktime()函數: <?php

echo date('Y-m-d', mktime(0,0,0,date('n')-1,1,date('Y'))); //2012-03-01

?>

請參閱實際操作 You should use the mktime() function: <?php

echo date('Y-m-d', mktime(0,0,0,date('n')-1,1,date('Y'))); //2012-03-01

?>

See In Action

嘗試這個: $dates = array("10 October 13:23", "12 November 08:12", "10 October 13:23");

foreach($dates as $d){

$exploded = explode(" ", $d);

$newDate = array_slice($exploded, 0,2,true)+array(2=>"2012")+array(3 => $exploded[2]);

...

使用midnight : echo mydate(strtotime('midnight first day of this month'));

演示 Use midnight: echo mydate(strtotime('midnight first day of this month'));

Demo

每月使用j ,而不是n是數字月份: php $date = date('l, F j, Y', strtotime($this->input->post('date')));

在行動中看到它 Use j for day of the month, not n which is the numeric month: php $date = date('l, F j, Y', strtotime($this->input->post('date')));

See it in action

這是不同版本的PHP的問題。 在php 5.2.7中有一個BC,來自文檔 : 在5.2.7之前的PHP 5中,請求在該工作日是該月的第一天的一個月中給定工作日的給定事件將錯誤地將一周添加到返回的時間戳。 這已在5.2.7及更高版本中得到糾正。 演示 服務器A的PHP> 5.2.7,服務器B的PHP <5.2.7。 This is a problem with different version of php. There is a BC in php 5.2.7, from the documen

...

這部分無關 - 問題被編輯 由于時區差異。 $ start是在'Rainy River時區'計算的,而$ middle和$ end是UTC時間。 “雨河時區與UTC的時差為-06:00小時 (正好是第一次與第二次和第三次結果之差)。 更新1 - 解決方案 看來問題出現在時間周圍的某個地方。 由于某種原因,它會產生一天的偏差(需要進一步解釋)。 一個簡單的解決方案是從該日期減去一秒鐘,它會產生正確的結果。 $timezone = new DateTimeZone('UTC');

$start = n

...

那么,關鍵字“的”是解決方案, strtotime(“2016-01”的第一個星期五)輸出1.1.2016 Well, the keyword "of" is the solution, strtotime("first friday of 2016-01") outputs 1.1.2016

您發布的代碼以您描述的方式失敗; 似乎PHP手冊頁中的描述(正如SilentGhost所提到的,只是用戶注釋)是未經過驗證的代碼。 如果您需要某個特定月份的最后一天,請嘗試以下操作: date('Y-m-d', strtotime("2009-12 next month - 1 hour"));

The code you posted fails in the manner you described; it seems that the description in the PHP manua

...

您在嘗試檢索該月的第一天時缺少關鍵字 echo date('Y-m-d', strtotime('First Monday of '.date('F o', strtotime("-4 months")));

我找到了這個bug報告的信息 我目前的版本是PHP 5.4.4,以防它仍然不適合你 You are missing the keyword of when trying to retrieve the first day of the month echo date('Y-m-d', st

...

總結

以上是生活随笔為你收集整理的每天的0点php,使用strtotime,这个月的第一天凌晨0点在PHP?(Using just strtotime, 0 am first day of this month in PHP?)...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。