Jump to content

How to timestamp using standard time instead of military?


Recommended Posts

This is what I have so far and it works great. Just need to get the AM PM thing going instead of military. BTW I am adding 3 hours to the stamp

 

Send(@MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR +3 & ":" & @MIN & ":" & @SEC)

 

07/10/2017 13:56:29

I would like it to look like this

07/10/2017 1:56:29 PM

Edited by Teckx
Link to comment
Share on other sites

You can use _Now() by itself that does exactly what you want.

Send(_Now())

EDIT: Just saw that you're also adding 3 hours to the time. In that case I recommend grabbing the @HOUR macro and then converting it to normal time by subtracting 12 if necessary. Something like:

$hr = @HOUR
$am = True
If($hr > 12) Then
    $hr = $hr - 12
    $am = False
EndIf

You should be able to do something similar to that and incorporate it into your code.

Edited by anthonyjr2

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Link to comment
Share on other sites

Not so easy. After 21:00 (9:00 PM) if 3 hours are added then the day changes... and so on  :)

#include <Date.au3>

; first: add 3 hours to current date/time and split the result
Local $d, $t
_DateTimeSplit(_DateAdd("h", 3, _NowCalc()), $d, $t)

; second: format as needed and put the am/pm thing
$time = $d[3] & "/" & $d[2] & "/" & $d[1] & " " & _ 
    StringFormat("%02d:%02d:%02d", Mod($t[1], 12), $t[2], $t[3]) & " " & _ 
    (Floor($t[1]/12) = 0 ? "AM" : "PM")

Msgbox(0,"", $time)

 

Edited by mikell
added comments
Link to comment
Share on other sites

17 minutes ago, mikell said:

Not so easy. After 21:00 (9:00 PM) if 3 hours are added then the day changes... and so on  :)

#include <Date.au3>

; first: add 3 hours to current date/time and split the result
Local $d, $t
_DateTimeSplit(_DateAdd("h", 3, _NowCalc()), $d, $t)

; second: format as needed and put the am/pm thing
$time = $d[3] & "/" & $d[2] & "/" & $d[1] & " " & _ 
    StringFormat("%02d:%02d:%02d", Mod($t[1], 12), $t[2], $t[3]) & " " & _ 
    (Floor($t[1]/12) = 0 ? "AM" : "PM")

Msgbox(0,"", $time)

 

very nice

thank you very much

Link to comment
Share on other sites

I hate to ask another question after receiving that help from you .  Im sure its something simple that I havnt encountered yet

how could I bypass it displaying the time in messagebox and have it type at my cursor

so $time is a variable but if I do Send("$time") obviously it just sends me $time

Edited by Teckx
english
Link to comment
Share on other sites

  • Developers
5 minutes ago, Teckx said:

I hate to ask another question

No you don't. ;)

5 minutes ago, Teckx said:

so $time is a variable but if I do Send("$time") obviously it just sends me $time

And why do you think this is the case? maybe you have something around the variable making it a literal string?

Jos

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

Just now, Jos said:

No you don't. ;)

And why do you think this is the case? maybe you have something around the variable making it a literal string?

Jos

yea I tried without the quotes and receive ..

you know what it didn't work 5 minutes ago now it does.

A Magician you are, Master Yoda

 

 

Link to comment
Share on other sites

  • Developers
Just now, Teckx said:

you know what it didn't work 5 minutes ago now it does.

Bullshit ... and you know it! ;)

 

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

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...