Hello,
Is it possible to perform a DateTime calculation to get current time minus 10 minutes? For example
cTenMinutesBefore := DateTime() - 10
Thank you!
DateTime calculation
- cdmmaui
- Posts: 693
- Joined: Fri Oct 28, 2005 9:53 am
- Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong
- Contact:
Re: DateTime calculation
I figured it out.
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: DateTime calculation
Code: Select all | Expand
DateTime() - ( 10 / ( 24 * 60 ) )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- cdmmaui
- Posts: 693
- Joined: Fri Oct 28, 2005 9:53 am
- Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong
- Contact:
Re: DateTime calculation
Hi Rao, thank you. I had found it in xHarbour documentation
Re: DateTime calculation
dear all,
I would also like to kindly ask assistance with date and time handling.
specifically: is it possible to convert a harbour date variable into a "unix timestamp expressed in milliseconds" (hope this is the correct term)?
I am working on a project where I need to pass arrival and departure dates to a url.
the expected format is something like this:
[url]https://be.bookingexpert.it/book/simple/noavail?checkin=1707523200000&checkout=1708124400000&hotel=11308&guesttypes[0][37]=2&ages[0][37]=18&ages[0][37]=18&layout=782&lang=de¤cy=EUR&beginsearch=1&isnewsearch=1&searchId=218d74e0-8bfd-43df-970d-e5f4c6f59ed1&nsid=fb5f36a1-7c31-40de-9c6e-8c7837b6a130&winding=1&searchId=e7cfbe49-4afc-4c0e-ae7b-69180634164f[/url]
where checkin=1707523200000 is the 10.02.2024 and
checkout=1708124400000 is the 17.02.2024
thank you very much in advance and kind regards
ruth
I would also like to kindly ask assistance with date and time handling.
specifically: is it possible to convert a harbour date variable into a "unix timestamp expressed in milliseconds" (hope this is the correct term)?
I am working on a project where I need to pass arrival and departure dates to a url.
the expected format is something like this:
[url]https://be.bookingexpert.it/book/simple/noavail?checkin=1707523200000&checkout=1708124400000&hotel=11308&guesttypes[0][37]=2&ages[0][37]=18&ages[0][37]=18&layout=782&lang=de¤cy=EUR&beginsearch=1&isnewsearch=1&searchId=218d74e0-8bfd-43df-970d-e5f4c6f59ed1&nsid=fb5f36a1-7c31-40de-9c6e-8c7837b6a130&winding=1&searchId=e7cfbe49-4afc-4c0e-ae7b-69180634164f[/url]
where checkin=1707523200000 is the 10.02.2024 and
checkout=1708124400000 is the 17.02.2024
thank you very much in advance and kind regards
ruth
- Antonio Linares
- Site Admin
- Posts: 42256
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: DateTime calculation
Dear Ruth,
good morning
I just copied and pasted your post into chatgpt and the answer seems fine (not exactly correct, but the explanation seems fine)
good morning
I just copied and pasted your post into chatgpt and the answer seems fine (not exactly correct, but the explanation seems fine)
Yes, it looks like the timestamp you provided is in milliseconds since the Unix epoch. To convert a Harbour date variable into a Unix timestamp expressed in milliseconds, you need to follow these steps:
Get the date value from the Harbour date variable.
Convert the date value to the Unix timestamp, which is the number of seconds since the Unix epoch (January 1, 1970).
Multiply the Unix timestamp by 1000 to convert it to milliseconds.
Here's a simple example in Harbour script:
Code: Select all | Expand
// Assuming you have a Harbour date variable named myDate
myDate := DToT(DATE(2024, 02, 10))
// Step 2: Convert to Unix timestamp (seconds)
unixTimestamp := myDate - DATE(1970, 01, 01)
// Step 3: Convert to milliseconds
unixTimestampMilliseconds := unixTimestamp * 1000
? "Unix Timestamp in milliseconds:", unixTimestampMilliseconds
This code assumes myDate contains the Harbour date variable you want to convert. Please replace myDate with your actual date variable. The resulting unixTimestampMilliseconds will be in the format you can use in your URL.
Make sure to adjust the code based on your actual Harbour date handling methods, as it may vary depending on the context of your project.
Re: DateTime calculation
Dear Antonio,
thank you very much...this is wonderful!!!
it is running now
have a nice weekend and kind regards
ruth
thank you very much...this is wonderful!!!
it is running now
have a nice weekend and kind regards
ruth