php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48306 Wrong date for big U digit
Submitted: 2009-05-16 20:01 UTC Modified: 2009-05-16 20:33 UTC
From: jhoseinii at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.9 OS: Linux Fedora Centos 5.x
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jhoseinii at gmail dot com
New email:
PHP Version: OS:

 

 [2009-05-16 20:01 UTC] jhoseinii at gmail dot com
Description:
------------
Hi,

I tried to use date for convert U (seconds passed from 1970.1.1 up to about 2030, but it returned some unsuitable result
check this sample: 

$U = 2191928815;
echo gmdate('Y.m.d H:i:s', $U); // 1903.05.12 06:38:39




Reproduce code:
---------------
non

Expected result:
----------------
non

Actual result:
--------------
non

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-16 20:18 UTC] rasmus@php.net
Works fine on 64-bit Linux (Debian) for me.  I get:

2039.06.17 13:06:55

However, you are probably on a 32-bit platform in which case your timestamps are going to go negative at 2^32 which is 2147483648.  So, in your case your timestamp is actually the same as -2103038481 (-2^32 + (2191928815 - 2^32) which is exactly and correctly 1903.05.12 06:38:39

So, the short version is that if you want to play with Unix timestamps that represent times after Jan.19 2038 you are going to need to go 64-bit.
 [2009-05-16 20:33 UTC] derick@php.net
Actually, you can do this things on 32-bit as well, like:

$U = 2191928815;
$d = date_create( "@$U" );
echo date_format( $d, 'Y.m.d H:i:s' );
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jun 03 00:01:26 2025 UTC