ID:               20478
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-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] [EMAIL PROTECTED]

<?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

Reply via email to