:: Forum >>

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

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([str, date, date]);

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!
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. :)
Thursday, July 27, 2006

This topic is archived.

Back to support forum

Forum search