Teckx

How to timestamp using standard time instead of military?

12 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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=

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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
1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted

Yeah you're right, I was still half asleep when I wrote that so I didn't consider the other edge possibilities :D


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#5 ·  Posted

2 minutes ago, anthonyjr2 said:

the other edge possibilities

Back to the future  :P

Share this post


Link to post
Share on other sites

#6 ·  Posted

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#8 ·  Posted

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted

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

 

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

there may have been some user error involved o:)

Share this post


Link to post
Share on other sites

#12 ·  Posted

1 hour ago, Teckx said:

A Magician you are, Master Yoda

How true   :D

Share this post


Link to post
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