Convert @Created to Unix Timestamp using @formula
In a multi-language enabled application I’m using JSON from a view as a datasource for a jqGrid in an XPage. To convert the date-time in the JSON, I need the date/time value a UNIX timestamp.
It’s easy in LS, but I do not want to change the programming of the application, to calculate the timestamp on document creation and store the value in an item on the document.
To convert the @created date into an UNIX timestamp I use the following @formula:
_seconds:=
@ToNumber(@Hour(@Created))*3600 +
@ToNumber(@Minute(@Created)) * 60 +
@ToNumber(@Second(@Created));
((@BusinessDays(@Date(1970;1;1);@Created) - 1 )*86400) + _seconds
Update: Well, the formula is nice and does what it should. But there is a much easier way to achieve the aim.
@Created - @Date(1970;1;1;0;0;0) - 1
gives exactly the same result …