Sam's notebook

Wrong date? Just add 3½ days July 3rd, 2018, 1PM

Programming

More PHP date weirdness, this time in the Cargo extension for MediaWiki:

+		// 'o' is better than 'Y' because it does not add leading
+		// zeroes to years with fewer than four digits.
+		// For some reason, though, this fails for some years -
+		// returning one year lower than it's supposed to - unless you
+		// add the equivalent of 3 days or more to the number of
+		// seconds. Is that a leap day thing? Weird PHP bug? Who knows.
+		// Anyway, it's easy to get around.
+		$yearString = date( 'o', $seconds + 300000 );

[No comments] [Keywords: , , , ] [Permanent link]

Leave a Reply

Your email address will not be published. Required fields are marked *