开发者

Handling special case of calendar with PHP/Javascript

开发者 https://www.devze.com 2023-04-01 02:04 出处:网络
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开发者_开

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号