:: Forum >> Version 2 >>

Unix Timestamp... any suggestions how to handle it?

More information on this topic is available in the documentation section: /aw.formats.date/setdataformat.html.

How all. I have a grid in which I load an AJAX fetched XML. I use the following code to set the Formats:

var str = new AW.Formats.String;
    var 
date = new AW.Formats.Date;

    
obj.setCellFormat([strdatedate]);
 
Unfortunately a unix timestamp such as PHP and nearly all other unix based systems use it, is not supported. I only get an error. Does anyone have a quick and clean solution how to translate my unix timestamp to something the AW.Formats.Date can handle? A server-side solution won't do here.

Thanks in advance!
Yereth
Friday, July 21, 2006
As far as I understand the unix timestamp is the same as internal js date representation (just in seconds instead of milliseconds), so you just have to multiply it by 1000 :-)

var uxdate = new AW.Formats.Date;
uxdate.dataToValue = function(d){return Number(d)*1000};
uxdate.setTextFormat("dd/mmm/yy hh:mm:ss");
 
Instead of calling setDataFormat() method to specify incoming data format you just manually create required converter function (dataToValue). Then valueToText conversion works as usual with the help of setTextFormat() call.
Alex (ActiveWidgets)
Friday, July 21, 2006
Thanks Alex. Works like a charm. :)
Yereth
Thursday, July 27, 2006



This topic is archived.

Back to /aw.formats.date/setdataformat.html

Documentation:

Forum search