I need to calculate the Unix Time stamp.
eg: The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds
Is there a function that does this built in?
Epoch & Unix Timestamp
Moderator: Rathinagiri
Re: Epoch & Unix Timestamp
I don't know whether there's one built in, but this may help:
function getposix()
posixday = date() - ctod("01/01/1970")
posixhrs = posixday * 24
posixmin = posixhrs * 60
posixsec = posixmin * 60
tdyhrs2sec = int(val(substr(time(),1,2))) * 3600
tdymin2sec = int(val(substr(time(),4.2))) * 60
tdysec2sec = int(val(substr(time(),7,2)))
todaysec = tdyhrs2sec + tdymin2sec + tdysec2sec
Return posixsec + todaysec
It may be off by one day (86,400 seconds), but if you have something to compare it to, that should be easily fixed.
And I'm not sure about the difference from wherever you are to GMT, but again, if that's an issue, it would be a constant or an easily built-in variable.
function getposix()
posixday = date() - ctod("01/01/1970")
posixhrs = posixday * 24
posixmin = posixhrs * 60
posixsec = posixmin * 60
tdyhrs2sec = int(val(substr(time(),1,2))) * 3600
tdymin2sec = int(val(substr(time(),4.2))) * 60
tdysec2sec = int(val(substr(time(),7,2)))
todaysec = tdyhrs2sec + tdymin2sec + tdysec2sec
Return posixsec + todaysec
It may be off by one day (86,400 seconds), but if you have something to compare it to, that should be easily fixed.
And I'm not sure about the difference from wherever you are to GMT, but again, if that's an issue, it would be a constant or an easily built-in variable.
Re: Epoch & Unix Timestamp
That might be a start.
Foxpro works with this. Still have to adjust for time zone.
DATETIME() - {^1970/01/01 00:00:00}
HMG doesn't work. It returns a totally wrong number.
I need this to be accurate to the minute.
Foxpro works with this. Still have to adjust for time zone.
DATETIME() - {^1970/01/01 00:00:00}
HMG doesn't work. It returns a totally wrong number.
I need this to be accurate to the minute.
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Epoch & Unix Timestamp
Russ,
If you can't get it with HMG then do a trick. Execute a small PHP program (which does give the time) and retrieve the output. A bit tricky but it should work. That's how I retrieve my IPADDRESS.
If you want to use this, let me known for the details.
Serge
If you can't get it with HMG then do a trick. Execute a small PHP program (which does give the time) and retrieve the output. A bit tricky but it should work. That's how I retrieve my IPADDRESS.
If you want to use this, let me known for the details.
Serge
There's nothing you can do that can't be done...
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Epoch & Unix Timestamp
Please look at here.RussBaker wrote:I need to calculate the Unix Time stamp.
eg: The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds
Is there a function that does this built in?
By the way; are you sure that literal date time value operator {^ } supporting by Harbour ?
Viva HMG
Viva INTERNATIONAL HMG
Re: Epoch & Unix Timestamp
It compiled and ran. However, the result was incorrect. So you are probably correct in that Harbour doesn't support "^".esgici wrote:By the way; are you sure that literal date time value operator {^ } supporting by Harbour ?
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Epoch & Unix Timestamp
Definitely Harbour supports this VFP like datetime constant notation. But probably date-time implementation is different. Here some information found, hopefully may be helpful for you.RussBaker wrote:It compiled and ran. However, the result was incorrect. So you are probably correct in that Harbour doesn't support "^".esgici wrote:By the way; are you sure that literal date time value operator {^ } supporting by Harbour ?
Viva HMG
Viva INTERNATIONAL HMG