Edit report at https://bugs.php.net/bug.php?id=55089&edit=1

 ID:                 55089
 Updated by:         [email protected]
 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

Reply via email to