Req #55089 [Opn->Wfx]: strptime() with UNIX timestamps
| From: | aharvey@php.net | Date: | Fri, 01 Jul 2011 07:11:41 +0000 |
| Subject: | Req #55089 [Opn->Wfx]: strptime() with UNIX timestamps | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161447@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55089&edit=1
ID: 55089
Updated by: aharvey@php.net
Reported by: webmaster at raphaelmichel dot de
Summary: strptime() with UNIX timestamps
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Date/time related
Operating System: any
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2011-06-30 10:12:02] webmaster at raphaelmichel dot de
Description:
------------
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:
---------------
<?php
function strptime_array_to_timestamp($array)
{
if(!empty($array['unparsed']))
{
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);
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55089&edit=1