Jump to content

Time format help needed. -simple for someone . . .


Recommended Posts

Hey guys, Can anyone help me with this . . . I haven't worked with time much and can't find much in the help example other than time difference.

I have included an example below. Thanks!

#include <Date.au3>


;1 (Minutes) needs this format and rounded down to 00 for seconds
ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)
;needs this format, 15 minutes earlier, and rounded down to 00 for seconds
ConsoleWrite("2" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)



;2 (Hours) needs this format and rounded down to 00 for minutes, 00 for seconds
ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)
;needs this format, 15 hours earlier, and rounded down to 00 for minutes, 00 for seconds
ConsoleWrite("2" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)

Run it in SciTE and look at the bottom to see the results as they are . . . currently

Link to comment
Share on other sites

Ok,

After finding a post from PSaltyDS

#include <Date.au3>

;$sRET = (_DateAdd("s", -1 * ((2 * 86400) + (3 * 3600) + (4 * 60) + 5), _NowCalc()))

;1 (Minutes) needs this format and rounded down to 00 for seconds
ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)
;needs this format, 15 minutes earlier, and rounded down to 00 for seconds
ConsoleWrite("2" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( (_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())),3) & @CRLF)



;2 (Hours) needs this format and rounded down to 00 for minutes, 00 for seconds
ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)
;needs this format, 15 hours earlier, and rounded down to 00 for minutes, 00 for seconds
ConsoleWrite("2" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)

Any help rounding the Seconds down to 00?

Thanks!

Link to comment
Share on other sites

  • Developers

maybe:

ConsoleWrite("1" & StringTrimRight(_DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3),3) & ":00" & @CRLF)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

maybe:

ConsoleWrite("1" & StringTrimRight(_DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3),3) & ":00" & @CRLF)

#include <Date.au3>

$sRET = (_DateAdd("s", -1 * ((2 * 86400) + (3 * 3600) + (4 * 60) + 5), _NowCalc()));MsgBox(64, "Result", "2 days, 3 hours, 4 minutes, and 5 seconds ago was:  " & $sRET)

;1 (Minutes) needs this format and rounded down to 00 for seconds
ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)
;needs this format, 15 minutes earlier, and rounded down to 00 for seconds
ConsoleWrite("2" & _DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())),2) _
& " " & _DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())),3) & @CRLF)



;2 (Hours) needs this format and rounded down to 00 for minutes, 00 for seconds
ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF)
;needs this format, 15 hours earlier, and rounded down to 00 for minutes, 00 for seconds
ConsoleWrite("2" & _DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (15 * 3600) + (0 * 60) + 0), _NowCalc())),2) _
& " " & _DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (15 * 3600) + (0 * 60) + 0), _NowCalc())),3) & @CRLF)


ConsoleWrite("1" & StringTrimRight(_DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3),3) & ":00" & @CRLF)

Causes:

13/13/2009 3:20:47 PM
23/13/2009 3:05:47 PM
13/13/2009 3:20:47 PM
23/13/2009 12:20:47 AM
13/13/2009 3:20:47:00

Based on that, I was thinking maybe a string search and replace :?? once for the first one and twice for the second one . . .?

Link to comment
Share on other sites

  • Developers

Better?

ConsoleWrite("1" & _DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(StringTrimRight(_NowCalc(), 2) & "00",3) & @CRLF)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Jos, Thank you so much! Ya made that look harder than it was when I finally figured what you had done. It kept rejecting until I got the format right to accept the dateformat outside of the string change.

ConsoleWrite("1" & (_DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())), 2) & " " & (_DateTimeFormat(StringTrimRight((_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())), 5) & "00:00",3))) & @CRLF)

Works like a charm!

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
 Share

  • Recently Browsing   0 members

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