【问题标题】:Is there any numeric week number format which define week in many years?是否有任何数字周数格式可以定义多年中的一周?
【发布时间】:2015-12-31 09:43:38
【问题描述】:

使用 PHP 日期函数,我们可以轻松地使用从 0 变为 53 的周数。此计数每年从零开始。

我正在寻找一种日期格式,它给我一个数字值,该数字值每年都会继续,无需重置计数。

示例:

this_week = 578 (this week is in 2015)
newt_week must be = 579 (even it's in next year)

有没有为此目的的预定义格式?如果没有,哪种方法可以帮助我找到自定义解决方案?

【问题讨论】:

  • 什么时候开始? 2000 年?
  • 我有个主意,如果我们从 1970 年 1 月 1 日 erm 开始以秒为单位开始计数,并将其用作标准计数,然后以这种方式计算周数

标签: php date week-number


【解决方案1】:

我建议使用 PHP 时间函数转换为 UNIX 时间(自 1970-01-01 以来的秒数)。您可以通过除以一周中的秒数来找到自给定日期以来的周数。事实上,PHP 文档文档 (http://php.net/manual/en/function.time.php) 显示了一个非常类似于您想要实现的示例。

【讨论】:

  • You can find the number of weeks since a given date by dividing by number of seconds in a week。什么是夏令时、闰年、闰秒?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-02-22
  • 1970-01-01
  • 2017-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多