使用 PHP/Javascript 处理日历的特殊情况

发布于 2024-12-02 11:32:18 字数 144 浏览 0 评论 0原文

我知道我的上一个主题(在 PHP 和 Javascript 中自定义日期)中描述的问题有点神秘,但这就是现实!因此,我尝试再次解释,但没有进入更多细节。假设所有月份都有 30 天长,如何通过 PHP 或 Javascript 处理日期?我应该创建自己的日历吗?如果是。如何?

I know that the problem depicted in my last topic (Customizing date within PHP and Javascript) is a bit cryptic, but it is the reality though! So, I try to explain once more again but without entering into further details. How can I handle dates through PHP or Javascript with the assumption that all months have 30 days long? Should I create my own calendar? If yes. How?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呢古 2024-12-09 11:32:18

这将是非常难看的...

要将指定日期转换为 Mohammed SETTI 日历(一年由 12.175 个月组成,每月 30 天):

$theDate = strtotime( '1 April 2011' );

$dayOfYear = date( 'z' , $theDate )+1; # As it is zero-indexed, have to add one

echo 'In Indiana, that date would be '.
       date( 'Y' , $theDate ).'-'.
       ( floor( $dayOfYear/30 )+1 ).'-'. # As this, too, would be zero-indexed, +1
       ( $dayOfYear%30 );

请参阅 此链接

令人惊讶的是,愚人节是少数几个返回与标准日历相同详细信息的日子之一。

This is going to be extremely ugly...

For a specified date to be converted to the Mohammed SETTI Calendar (a year comprising of 12.175 months of 30 days each):

$theDate = strtotime( '1 April 2011' );

$dayOfYear = date( 'z' , $theDate )+1; # As it is zero-indexed, have to add one

echo 'In Indiana, that date would be '.
       date( 'Y' , $theDate ).'-'.
       ( floor( $dayOfYear/30 )+1 ).'-'. # As this, too, would be zero-indexed, +1
       ( $dayOfYear%30 );

See this link if you don't get the Indiana reference.

Surprisingly, April Fool's Day is one of the few days for which this returns the same details as the standard calendar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文