Hi all,
in my app I need to use the TimeStamp for a given date, and I'm using some code like this sample
B4X:
Dim startdateformat as String = DateTime.DateFormat
Dim starttimeformat as String = DateTime.TimeFormat
Dim MyTimeStamp as Long
DateTime.DateFormat = "yyyy-MM-dd"
DateTime.TimeFormat = "HH:mm:ss"
MyTimeStamp = DateTime.DateTimeParse("2014-09-17", "10:28:30")
The value of MyTimeStamp is 1410942510000, that is not correct because it should be 1410949710.
What I'm doing wrong?
@eps: the code I posted makes the following point: If you start with the timestamp and work backwards to calculate the string, you will get the date and time as I showed.
The point is; There is nothing wrong with KPmaster's code.
I'm trying to compose an html command to access the events stored in a Mobotix camera, and I've found a website (http://www.onlineconversion.com/unix_time.htm) where calculate the TimeStamp, and the value from the website is different, and I was trying to understand why.
Reading Mobotix API, I've found this, but TimeStamp values are not working and every search give an empty result:
searchbytime_start= Escaped stringTime Search Starting Time
Request an image via its timestamp [seconds.microseconds] since the Epoch (00:00:00 UTC, January 1, 1970).
If you are looking for 1410949710 as your answer you need to follow the below code: Please note that the web site you refer to calculates the seconds, B4A calculates the Milliseconds. The code below converts the milliseconds to secs and ignores time zone:
B4X:
DateTime.DateFormat = "yyyy-MM-dd"
DateTime.TimeFormat = "HH:mm:ss"
Dim MyTimeStamp As Long
DateTime.SetTimeZone(0)
MyTimeStamp = DateTime.DateTimeParse("2014-09-17", "10:28:30")/1000
Log(MyTimeStamp) 'displays what you are looking for which is: 1410949710
Thank you guys.
Now I'm investigating about the "seconds.microseconds" of the API, trying to understand how to pass the correct value to the Mobotix camera.
When finally I will find it, I will post here the solution.