[Gambas-user] Question about date conversion in Gambas v2

Olivier Cruilles linuxos at ...1896...
Mon Sep 27 21:16:55 CEST 2010


Thank's Benoit,

It's exactly that I need.

Olivier

Le 27 sept. 2010 à 20:44, Benoît Minisini a écrit :

>> Hi Benoit,
>> 
>> I have just a question about the possibility to convert in Gambas v2 a
>> variable in format Date to a value of this date in number of seconds like
>> in Unix command ?
>> 
>> In my projet i need to use date value in number of seconds and not in
>> standard format as for example this one: not    26-09-2010 17:08:00   but 
>>   in seconds  since 1970-01-01 00:00:00  =>  1285513680  seconds
>> 
>> I just want to know if it possible or not in Gambas v2 otherwise I will
>> continue to use the Unix command 'date' ?
>> 
>> Thank in advance,
>> 
>> Olivier Cruilles
>> Mail: linuxos at ...1896...
>> 
> 
> Dates are internally stored as a number of seconds and microseconds from a 
> Gambas epoch (which is not the Unix epoch), in GMT. 
> 
> When converted to Float, you get a number of days as integer part, and the 
> rest as decimal part.
> 
> So, if you need a unix timestamp, i.e. a number of seconds since epoch, you 
> just have to do that:
> 
> Print Int((CFloat(now) - CFloat(Date(1970, 1, 1))) * 86400)
> 
> Regards,
> 
> -- 
> Benoît Minisini
> 
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

Olivier Cruilles
Mail: linuxos at ...1896...






More information about the User mailing list