jmp Posted December 25, 2023 Author Posted December 25, 2023 9 minutes ago, Musashi said: Hmm, maybe some locale settings - for me it works, see : How? my case, I don't need seconds and space between minutes and AM/PM also
Musashi Posted December 25, 2023 Posted December 25, 2023 38 minutes ago, jmp said: How? my case, I don't need seconds and space between minutes and AM/PM also This is a forum with volunteers, not a 24/7 paid support hotline. You should have no problems adjusting these minor details based on the examples. Please show a little more commitment and don't expect us to spoon-feed you. Since I don't like to endorse indolence, I'm out of here. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
mikell Posted December 25, 2023 Posted December 25, 2023 You might also try the screwy way - meaning regex (what else ?) #include <Date.au3> $sDateTime = "25/12/2023 18:50:30" $res = Execute("'" & StringRegExpReplace($sDateTime, "(\d+)/(\d+)/(\d+) (\d+):(\d+).*", _ "' & _DateToMonth('$2',1) & ' $1 $3 ' & ('$4'>12 ? StringFormat('%02i', '$4'-12) & ':$5PM' : '$4:$5AM') & '") & "'") Msgbox(0,"", $res)
jmp Posted December 25, 2023 Author Posted December 25, 2023 1 minute ago, mikell said: You might also try the screwy way - meaning regex (what else ?) #include <Date.au3> $sDateTime = "25/12/2023 18:50:30" $res = Execute("'" & StringRegExpReplace($sDateTime, "(\d+)/(\d+)/(\d+) (\d+):(\d+).*", _ "' & _DateToMonth('$2',1) & ' $1 $3 ' & ('$4'>12 ? StringFormat('%02i', '$4'-12) & ':$5PM' : '$4:$5AM') & '") & "'") Msgbox(0,"", $res) Thank You @mikell But i created and its working well: #include <Date.au3> #include "DTC_Test.au3" Local $sIn_Date, $sOut_Date $sIn_Date = "25/12/2023 11:59:30" $sOut_Date = _Date_Time_Convert(_DateAdd('s', Random(2, 8, 1), _Date_Time_Convert($sIn_Date, "dd/MM/yyyy HH:mm:ss", "yyyy/MM/dd HH:mm:ss")), "yyyy/MM/dd HH:mm:ss", "MMM dd yyyy HH:mmTT") MsgBox(0, "Date-Conversion", "Webdate = " & $sIn_Date & @CRLF & "Newdate = " & $sOut_Date & @CRLF)
jmp Posted December 26, 2023 Author Posted December 26, 2023 17 hours ago, mikell said: Great @mikell When $sIn_Date = "25/12/2023 14:59:30" Its showing 14:59PM instead of 2:59PM
mikell Posted December 26, 2023 Posted December 26, 2023 Sorry, while my snippet works I didn't test yours #include <Date.au3> $sDateTime = "25/12/2023 14:59:30" $res = Execute("'" & StringRegExpReplace($sDateTime, "(\d+)/(\d+)/(\d+) (\d+):(\d+).*", _ "' & _DateToMonth('$2',1) & ' $1 $3 ' & ('$4'>12 ? StringFormat('%02i', '$4'-12) & ':$5PM' : '$4:$5AM') & '") & "'") Msgbox(0,"", $res)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now