[Gambas-user] How to convert unix timestamp into gambas date and time
Rolf Schmidt
rolf.frogs at ...221...
Fri Feb 3 15:48:42 CET 2012
Hi Rolf, hi Ron.
>>>> is there a function which allows to convert an unix timestamp into the
>>>> appropriated date/time in Gambas3?
>>>>
>>>> If, how is it called and how to use.
>>
>>> Take a look at this one:
>>> http://gambasdoc.org/help/lang/stat?v3
>>> file.stat should deliver a file date. Or did I get you wrong?
>>
>> For my problem, you get wrong. The unix timestamp is not only the time
>> of a file. It is the time in seconds since the 1. Jan. 1970. Even the
>> system clock only counts the seconds.
>>
>> My problem is, that a network application send a timestamp as a string.
>> I have to convert this string into Date and Time - which is usually done
>> in C or PHP or... by a function of a system library (which of course
>> know leap years).
>>
>> And some times I would like to generate a timestamp as well, for example
>> to send it to a database.
>>
>> Another helper out there?
>>
> May I nevertheless? :-)
>
> Ok, I tried around a bit, take a look:
>
> PUBLIC SUB Button1_Click()
> DIM t$ AS String
>
> t$ = CStr(CFloat(Now))
> Message.Info(t$)
>
> t$ = CDate(CFloat(t$))
> Message.Info(t$)
>
> END
>
> Does it help?
Not realy, than Now is a float value in "Exel"-Stil i.e. Days (since
when - don't hope since 1.1.1900) and seconds since midnight, but as I
wrote Unix timestamp is an integer i.e. has only seconds.
@Ron.
Your Module is excellent, but I can't belief, that a programming
language for the UNIX-environment isn't able to handle timestamps only
after "reinventig the wheel".
I think, we shoud ask Benoit why he didn't implement such a function or
where he hide the information.
Rolf.
More information about the User
mailing list