Unix Time

Monkey Forums/Monkey Programming/Unix Time

siread(Posted 2013) [#1]
Is there a way of retrieving the unix timestamp? Rather than pulling an array with GetDate a nice simple integer is easier to store and makes checking times much easier (minutes since last session for instance).


dawlane(Posted 2013) [#2]
You could write your own functions to access information using the C functions described here.


siread(Posted 2013) [#3]
Gah! I don't do native code. :P

I figured Monkey was getting the unix timestamp and converting it to date. Is that not the case? I traced it as far as native/gametarget.cpp but got lost there.


Markus(Posted 2013) [#4]
it is the count of seconds since 1.1.1970,
you can use this command and multiply the entrys with seconds, then add it together. with the date 1. 1. 1970 u must have 0 seconds, means sub this value later.

Function GetDate : Void ( date:Int[] )
Fills the date array with 7 integers representing the current date: year, month (1-12), day (1-31), hours (0-23), minutes (0-59), seconds (0-59) and milliseconds (0-999).


Goodlookinguy(Posted 2013) [#5]
I wrote native code to get the Unix timestamp some months ago in my library. You can just rip it from that if you 'don't do native code'... https://bitbucket.org/Goodlookinguy/xaddon/src/7fb57ea5d3c5b875f1b314744e947c1a6e95dbd3/basic/native/?at=default

May I ask why you don't do native code? Is it lack of knowing how those other languages work or is it the maintenance required to keep them working, or what?