Jump to content

Date to DateTime conversion


Recommended Posts

Good day.

I'm new to autoit and I ran into a problem here..

I need to check datetime value against a specific time in a current day.

So I tried to do it like this:

$reset = _DateAdd("h", $resetHour, _NowCalcDate())
If _DateDiff("s", $reset, $time) > 0 Then ...

However, _NowCalcDate returns just a date so it doesn't work. At least this piece of code makes me think so:

#include <Date.au3>
$reset = _DateAdd("h", 2, _NowCalcDate())

Is there any way to convert date into full datetime? Or to set particular absolute values (hour, minute etc) instead of just adding/substracting?

Sorry if this is explained in a help or was already answered, I wasn't able to find an answer myself.

Now that I think about it, I can substract what I need from the other variable ($time in my case) but that's just plain dirty.

Link to comment
Share on other sites

What you need it NowCalc():

#include <Date.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00) 
$iDateCalc = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of seconds since EPOCH: " & $iDateCalc )

; Calculated the number of Hours this year 
$iDateCalc = _DateDiff( 'h',@YEAR & "/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of Hours this year: " & $iDateCalc )
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...