I came across something I found a bit confusing when using the date()
function.
// Set up unix timestamp 03:34
$t = (3 * 60 * 60) + (34 * 60); // 12840 seconds
echo date('Y-m-d H:i',$t);
// displays Thu, 01 Jan 1970 13:34:00 not
// Thu, 01 Jan 1970 03:34:00
I was expecting date
to return 03:34, but it looks like it might have applied my timezone to it (+1000). My questions are a) does date()
apply the current timezone before formatting its output and b) is it possible in PHP to format a date without the application of the timezone? I need the 03:34 to stay that way, but I want to keep the simplicity of using unix-timestamps for my time maths, so would prefer not to use PHPs Date
class. Not a huge problem, just something more for interests sake.
Thanks guys Pete