php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30752 Converting Normal time to Unix time
Submitted: 2004-11-10 21:58 UTC Modified: 2004-11-10 23:16 UTC
From: ecit12 at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.8 OS: Fedore Core 2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ecit12 at hotmail dot com
New email:
PHP Version: OS:

 

 [2004-11-10 21:58 UTC] ecit12 at hotmail dot com
Description:
------------
Basically, I wanted to take a normal time stamp that is in the form of

YYYYMMDDHHMMSS and convert it to Unix format using the Date function.

The last $myDate variable should match the initial date, but it doesn't work.

It would be nice if PHP had more support for normal date formats instead of forcing ppl to convert to unix time. 

Reproduce code:
---------------
$myDate = 20041110113800 // 2004, Nov 10, 11:38:00
echo "The date in normal form: $myDate";
echo "<BR>";
$myDate = date("U",$myDate);
echo "The date in Unix format: $myDate";
echo "<BR>";
// added 00 for seconds since PHP has nothing for seconds
$myDate = date("YmdHi",$myDate)."00"; 
echo "The date in Normal format again: $myDate";

Expected result:
----------------
The date in normal form: 20041110113800
The date in Unix format: 792710664
The date in Normal format again: 20041110113800

Actual result:
--------------
The date in normal form: 20041110113800
The date in Unix format: 792710664
The date in Normal format again: 19950213132400

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-10 23:16 UTC] derick@php.net
Already submitted and this is going to work for PHP 5.1 but by using strtotime and date("YmdHis").
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 08:01:35 2024 UTC