Unix Time

Hi ,

I have declared the default date in String.

Dim TimeStamp As String = “2013-01-01 00:00:00”

Now i want to convert the same in as UnixTime.

Help me out

If you make TimeStamp a Date instead of a String, you get the Epoch by subtracting 2082844800 seconds

TimeStamp.TotalSeconds - 2082844800

A handy method for this could be:

Function DateToUTS(Extends d as Date) As Integer
Return d.TotalSeconds - 2082844800
End Function

[quote=209897:@Albin Kiland]And to turn it back to a date again:

Function UTSToDate(seconds As UInt64) As Date
Dim d As New Date
d.TotalSeconds = seconds + 2082844800
Return d
End Function[/quote]

[code]Dim d As New Date

d.TotalSeconds = 2082844800 + Timestamp + (d.GMTOffset * 3600)

Return d[/code]

[quote=209878:@Manikandan Karuppaiah]Hi ,

I have declared the default date in String.

Dim TimeStamp As String = “2013-01-01 00:00:00”

Now i want to convert the same in as UnixTime.

Help me out[/quote]

See http://developer.xojo.com/xojo-core-date$SecondsFrom1970