Handling special case of calendar with 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?
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.
精彩评论