real millisecs / unix timestamp

Monkey Forums/Monkey Programming/real millisecs / unix timestamp

pantson(Posted 2013) [#1]
Hi

I'm sure I read that this function now existed, but maybe it was removed in v67.
Is there a way to get the unix timestamp in monkey?


Goodlookinguy(Posted 2013) [#2]
Diddy has a function that will return the unix timestamp called "RealMillisecs" : https://bitbucket.org/swoolcock/diddy/overview


c.k.(Posted 2013) [#3]
A UTC-formatted timestamp is "YYYY-MM-DDTHH:MM:SSZ". How do I get that from diddy's RealMillisecs()?

(I don't see a way to make diddy spit out "03" for March (using GetMonth()) instead of just "3".)

[monkeycode]
Local ts:String = GetYear() + "-" + GetMonth() + "-" + GetDayOfMonth() + "T" + GetHours() + ":" + GetMinutes() + ":" + GetSeconds() + "Z"

[/monkeycode]


EdzUp(Posted 2013) [#4]
Couldnt you do:
Function TwoDigitMonth:String()
   Local GMonth:String = GetMonth
   if GMonth.Length<2 then Return "0"+GMonth        'if its 1 then its <10 so we need a 0 on the front
   Return GMonth
End


:D


EdzUp(Posted 2013) [#5]
Couldnt you do:
Function TwoDigitMonth:String()
   Local GMonth:String = GetMonth
   if GMonth.Length<2 then Return "0"+GMonth        'if its 1 then its <10 so we need a 0 on the front
   Return GMonth
End


:D


EdzUp(Posted 2013) [#6]
Couldnt you do:
Function TwoDigitMonth:String()
   Local GMonth:String = GetMonth
   if GMonth.Length<2 then Return "0"+GMonth        'if its 1 then its <10 so we need a 0 on the front
   Return GMonth
End


:D


c.k.(Posted 2013) [#7]
Yes.
Yes.
Yes.

:-D

It would be better if we could get something like:

diddy.UTCTime()

or

diddy.RealMillisecs("Y-M-D\TH:M:S\Z")

:-)


EdzUp(Posted 2013) [#8]
Crikey never had triple post before :s

Yeah I do agree but sometimes its the coder that has to provide the workaround :D