TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   strptime (http://www.talkphp.com/general/4133-strptime.html)

Kalle 04-13-2009 10:31 PM

strptime
 
Hey

So I've been playing about with BSD's strptime() implementation (written in C). Currently PHP does not support strptime() on Windows because the lack of that function in Microsoft's Standard C Library, however I was wondering if anyone of you non Windozers could try the following script (under prefered the most recent version of php) and post the output:

PHP Code:

<?php
    date_default_timezone_set
('UTC');

    
$format '%d/%m/%Y %H:%M:%S';
    
$strf strftime($formatmktime(1554191032004));

    echo 
"$strf\n";

    
print_r(strptime($strf$format));
?>

Currently on my local Windows build I get:
Code:

03/10/2004 15:54:19
Array
(
    [tm_sec] => 19
    [tm_min] => 54
    [tm_hour] => 15
    [tm_mday] => 3
    [tm_mon] => 9
    [tm_year] => 34
    [tm_wday] => 0
    [tm_yday] => 0
    [unparsed] =>
)

Comparing it to a result generated by a Linux box:
Code:

03/10/2004 15:54:19
Array
(
    [tm_sec] => 19
    [tm_min] => 54
    [tm_hour] => 15
    [tm_mday] => 3
    [tm_mon] => 9
    [tm_year] => 104
    [tm_wday] => 0
    [tm_yday] => 276
    [unparsed] =>
)

Which indicates that the tm_year is off by 70 in my sample and the tm_yday isn't even getting set. So I'm eager to find out the results so I can compare if they are consistent, and if anyone got a *BSD box and is able to run this script on it and tell me the results it would be just perfect! =)


Cheers

Salathe 04-13-2009 11:16 PM

Here's what comes out of an OS X box, if that helps:
Code:

03/10/2004 15:54:19
Array
(
    [tm_sec] => 19
    [tm_min] => 54
    [tm_hour] => 15
    [tm_mday] => 3
    [tm_mon] => 9
    [tm_year] => 104
    [tm_wday] => 0
    [tm_yday] => 0
    [unparsed] =>
)


Kalle 04-13-2009 11:47 PM

Quote:

Originally Posted by Salathe (Post 23066)
Here's what comes out of an OS X box, if that helps:
Code:

03/10/2004 15:54:19
Array
(
    [tm_sec] => 19
    [tm_min] => 54
    [tm_hour] => 15
    [tm_mday] => 3
    [tm_mon] => 9
    [tm_year] => 104
    [tm_wday] => 0
    [tm_yday] => 0
    [unparsed] =>
)


Thanks Salathe, OSX is a BSD variant so it should be good enough :)

Kalle 04-14-2009 01:50 AM

Great I got it working with the same results as you Salathe, for those interested I've created a diff:
http://www.pastie.org/445636

;)


All times are GMT. The time now is 01:53 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0