#20478 [Opn->Bgs]: strftime problem with timestamp from 2000-01-01/02

From: Date: Mon, 18 Nov 2002 13:33:46 +0000
Subject: #20478 [Opn->Bgs]: strftime problem with timestamp from 2000-01-01/02
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-25186@lists.php.net to get a copy of this message
ID: 20478 Updated by: iliaa@php.net Reported By: thomas.schuessler@michel-consulting.de -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: linux PHP Version: 4.2.2 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. Use strftime('%Y', $timestamp) not strftime('%G', $timestamp). %G - The 4-digit year corresponding to the ISO week number (see %V). This has the same format and value as %Y, except that if the ISO week number belongs to the previous or next year, that year is used instead. Previous Comments: ------------------------------------------------------------------------ [2002-11-18 06:34:40] thomas.schuessler@michel-consulting.de <?php $mysql_date= '2000-01-01'; list($year, $month, $day) = explode('-', $mysql_date); $timestamp = mktime(0,0,0,$month,$day,$year); print 'mysql date:'.$mysql_date.'<br />'; print 'timestamp: '.$timestamp.'<br /><br />'; print 'strftime: '.strftime('%G', $timestamp).'<br />'; print 'date: '.date('Y', $timestamp); ?> prints: mysql date:2000-01-01 timestamp: 946681200 strftime: 1999 <------- WRONG! date: 2000 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20478&edit=1

« previous php.bugs (#25186) next »