Skip to content
Tags

mktime in php5

by Alex on March 16th, 2007

Came across a little bug in some of my code written a few years ago, after the server was upgraded to the PHP5 series, Brief details below:
In PHP 4.3.9:

<?php
date("F", mktime(0,0,0,1, 1, 1, 1));
// output: January
?>

In PHP 5.2.1:

<?php
date("F", mktime(0,0,0,1, 1, 1, 1));
// output: December
?>

This isn’t the exact code, so the logic of such a call won’t make much sense, but obviously, I was asking for it, with the bad assumptions. A quick work around was simply:

<?php
date("F", mktime(1,0,0,1, 1, 1, 1));
// output: January
?>

From → Uncategorized

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS