- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
当使用“第一天”修改日期时,PHP 中有一个非常奇怪的行为。
'first day' ' of'?
Sets the day of the first of the current month. (http://php.net/manual/de/datetime.formats.relative.php)
$currentMonthDate = new DateTime("2014-07-30 10:26:00.000000");
echo $currentMonthDate->format('Ym');
$currentMonthDate->modify('first day');
echo $currentMonthDate->format('Ym');
201407 / 201407 OK
$currentMonthDate = new DateTime("2014-07-31 10:26:00.000000");
echo $currentMonthDate->format('Ym');
$currentMonthDate->modify('first day');
echo $currentMonthDate->format('Ym');
201407 / 201408 WHY?
$currentMonthDate = new DateTime("2014-08-01 10:26:00.000000");
echo $currentMonthDate->format('Ym');
$currentMonthDate->modify('first day');
echo $currentMonthDate->format('Ym');
201408 / 201408 OK
我在运行 PHP 5.2 的生产服务器上发现了这种行为,所以我认为这是一个古老的错误,但它发生在我们测试服务器上的 PHP 5.3 ( http://phptester.net/ ) 和 5.5 中。
如果我在 PHP 5.2 中使用“本月的第一天”,则会发生相同的行为。在 PHP 5.5 中,“本月的第一天”按预期工作。
“第一天”的行为是错误吗?以及如何在 PHP 5.2 中获取“本月的第一天”而不在 string
和 date
之间进行奇怪的转换?
最佳答案
这个问题似乎是文档问题。
From Derick in bug #51096: "first day" and "last day" should be "+1 day" and "-1 day".
The documentation should be updated to reflect this behaviour, as currently the "first/last day of" section says the "of" is optional when it is not.
文档现已修复。所以 ' of '?
不再是可选的。
'first day of'
Sets the day of the first of the current month.
关于php - 第一天!= "first day of this month",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25054592/
我正在处理一些遗留代码,其中 java.util.Calendar 用于与日期相关的计算(基本上是添加月份)。现在我想在代码中用 java.time.LocalDate 替换 java.util.Ca
我刚刚在我正在学习的类(class)中开始使用 R,到目前为止我所做的是制作一个加载文件的脚本。 如果重要的话,我正在使用 Rstudio 1.0.44 使用 Ubuntu 14.04 运行 R。 我
我正在按月查询在 Laravel 中创建的用户,这是我的代码 $devlist = DB::table("users") ->select("id" ,DB::ra
C++20 计时类型/值之间有什么区别 month{7}和 months{7} ?有两个如此相似的名字是不是很困惑? 最佳答案 是的,同时拥有 month 可能会令人困惑。和 months第一次遇到这
我有一个数据库,其中包含我的用户完成的每个操作,并带有时间戳,如下所示: 用户名 ; Action ; 创建日期 我想评估一段时间内活跃用户的数量。我可以看到每周活跃的用户数 (count (dist
我在我的 Python 脚本中使用了 parsedatetime 库,似乎“上个月”有效,“下个月”但“本月”无效。 我错过了什么?有没有办法获取当月的第一天? 编辑:抱歉,这是一些代码: impor
我发现的大部分信息都不在 python>pandas>dataframe 中,因此是这个问题。 我想将 1 到 12 之间的整数转换为缩写的月份名称。 我有一个 df,它看起来像: client
在用户单击“下个月”或“上个月”后,我需要使用自定义 CSS 重新填充日期选择器。我正在点击 onChangeMonthYear 事件,但不知道用户要去哪条路(下个月或上个月)。有什么简单的内置东西可
我正在尝试计算一个月内产品的总销售额,但我希望它包括任何“空”月份(没有销售额)并且只选择最近的 12 个月。 到目前为止,这是我的代码。 declare @ProductNo int set @Pr
我有一个独特的问题,我根本无法解决。 所以我在 SQL Server 2005 中,我得到了以下要处理的数据: FISCAL_YEAR_START_MONTH INT(财政年度的第一个月) COUNT
我正在进行的一个项目需要获取过去 12 个月中每个月的平均发票总额。我可以通过执行 12 个查询(每月 1 个)轻松获得我需要的内容,但它非常丑陋,我最终得到 12 个唯一变量(id 而不是有一个循环
我希望用更好的不太详细的过程替换以下函数,用于从字符串确定数字月份值。有谁知道是否有可用于此目的的日期/日期时间函数?我没有注意到任何一个可以满足我的需求。 代码中的文本字符串正是我接收它们的方式。
我正在尝试获取过去 12 个月(包括当月)按月分组的记录数。不是从今年年初开始。 我有一个表 EVENTS 和一个字段 WODATE。我能做到 aFDQuery.Connection := Tra
我正在使用moment.js在 angularjs 应用程序中进行日期转换。我要打印Month number作为Month name 。我已经尝试过如下, {{item.ReviewMonth | d
我想通过 JPA 从 Oracle 数据库中选择实体,方法如下: Calendar cal = Calendar.getInstance(); cal.setTime(anOtherDate); Qu
我希望用一个更好的更简单的过程来替换以下函数,以便从字符串中确定数字月份值。有谁知道是否有可用于此的 Date/DateTime 函数?我没有注意到可以满足我的需求的。 代码中的文本字符串正是我接收它
我正在尝试获取过去 12 个月(包括当月)按月分组的记录数。不是从今年年初开始。 我有一个表 EVENTS 和一个字段 WODATE。我能做到 aFDQuery.Connection := Tra
我读到“将日期字符串转换为mysql日期时间字段”:但这对我没有帮助 所以我想做的是将dat文件读入mysql中的空表。 table CLIMBED(TRIP_ID int,PEAK VARCHAR(
我有这样的查询: SELECT EXTRACT(MONTH FROM d.mydate) AS synmonth, SUM(apcp) AS apcptot FROM t_synop_data2 d
一些需要更改 df header 的 Django 格式问题。 测试数据: Test_Data = [ ('Year_Month', ['Done_RFQ','Not_
我是一名优秀的程序员,十分优秀!