|
Posted by Bruno B B Magalhγes on 07/08/05 01:45
Hi Richard,
Well, I took a look at, and I think it is TOO complex to handler a
simple thing..
Well, that's my little contribution:
function str2time($input = '12/31/1969')
{
$year = substr($input, -4);
$input = substr_replace($input, 1976 , -4);
return floor(strtotime($input) + (($year - 1976) *
(31557376.189582)));
}
It work with ONLY a few hours more or less compared to my MacOS
strtotime function, now I don't know which one is more accurate..
Well, why did you choose the year 1976, because it's an bisixth(?)
year. So it was a matter of simple math.
I would appreciate any help from everybody to:
As I suppose that the last 4 digits are the year, I would like a
pattern that could match a four digits number inside a string.
Any body know how many seconds and microseconds have a year, I found
a round number (31557376.189582).
Well, any help is appreciate.
At least now I can work on a windows box.
Best Regards,
Bruno B B Magalhaes
On Jul 7, 2005, at 3:42 PM, Richard Davey wrote:
> Hello Bruno,
>
> Thursday, July 7, 2005, 7:04:44 PM, you wrote:
>
> BBBM> I've read the manual, and the ADOdb Date package functions, and
> BBBM> I am not using this because I want to keep my framework simple,
> BBBM> flexible, and fast.
>
> BBBM> Well, I just want a simple way to translate dates (I know what
> BBBM> is the input format) to unix timestamp, with ability to do this
> BBBM> with dates before 1970, and after 2023, is there any way?
>
> Personally I'd use the Pear Date package. It's stable, well formed and
> will do exactly what you require: http://pear.php.net/package/Date
>
> Even if you don't like the thought of using it - you can always pour
> over the source code to look at their methods and see how they handle
> it.
>
> Best regards,
>
> Richard Davey
Navigation:
[Reply to this message]
|