php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20478 strftime problem with timestamp from 2000-01-01/02
Submitted: 2002-11-18 06:34 UTC Modified: 2002-11-18 07:33 UTC
From: thomas dot schuessler at michel-consulting dot de Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.2.2 OS: linux
Private report: No CVE-ID: None
 [2002-11-18 06:34 UTC] thomas dot schuessler at michel-consulting dot 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-18 07:33 UTC] iliaa@php.net
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. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 07:01:31 2024 UTC