|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #55089 strptime() with UNIX timestamps
Submitted: 2011-06-30 10:12 UTC Modified: 2011-07-01 03:11 UTC
From: webmaster at raphaelmichel dot de Assigned:
Status: Wont fix Package: Date/time related
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
24 - 17 = ?
Subscribe to this entry?

 [2011-06-30 10:12 UTC] webmaster at raphaelmichel dot de
It would be awesome to have a function in the standard library which either one working like strptime() but returning a UNIX timestamp or one converting an array like those returned by strptime() into a UNIX timestamp.

Test script:
function strptime_array_to_timestamp($array)
        return false;

    return mktime( isset($array['tm_hour']) ? $array['tm_hour']      : null, 
                   isset($array['tm_min'])  ? $array['tm_min']       : null,
                   isset($array['tm_sec'])  ? $array['tm_sec']       : null,
                   isset($array['tm_mon'])  ? 1+$array['tm_mon']     : null,
                   isset($array['tm_mday']) ? $array['tm_mday']      : null,
                   isset($array['tm_year']) ? 1900+$array['tm_year'] : null);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-01 03:11 UTC]
-Status: Open +Status: Wont fix
 [2011-07-01 03:11 UTC]
date_create_from_format() will give you a DateTime object, from which it's very 
easy to get a timestamp. As an added bonus, it behaves sensibly cross-platform, 
unlike strptime().

Closing won't fix.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 26 08:03:48 2022 UTC