iceberg Posted August 21, 2006 Share Posted August 21, 2006 hi, i need your great help to convert the following: after running my script, i get the following output: 2006/08/21 16:40:08 how do i actually convert this so that the output reads as such for my second command? 21/08/2006 4:40 PM thanks. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
Rad Posted August 21, 2006 Share Posted August 21, 2006 (edited) Would be easier if we had a few lines to work with... But.. try something like this: $date = "2006/08/21" $temp1 = StringLeft($Date,4) $temp2 = StringMid($Date,6,2) $temp3 = StringRight($Date,2) $Date = $Temp3 &"/"& $Temp2 &"/"& $Temp1 msgbox(0,"",$Date) $time = "16:40:08" $Temp1 = StringLeft($time,2) $Temp2 = StringMid($time,4,2) If $temp1 > 12 Then $Temp1 = $temp1 - 12 $time = $Temp1 &":"& $Temp2 msgbox(0,"", $time) Pretty lame way to do it though, theres probrably a time/date format option somewhere Edited August 21, 2006 by Rad Link to comment Share on other sites More sharing options...
buzz44 Posted August 21, 2006 Share Posted August 21, 2006 (edited) What is your current script? To get in it 12 hour format simply do the Hour - 12 (ie. 16 - 12 = 4). As for the Day/Month/Year, use StringSplit() and re-order them or change the regional settings on your computer. Seek the helpfile's "Date Management" catergory in Contents for further enlightenment . Edited August 22, 2006 by Larry qq Link to comment Share on other sites More sharing options...
Rad Posted August 21, 2006 Share Posted August 21, 2006 Oh yea string split sounds better $date = "2006/08/21" $temp = StringSplit($date,"/") $Date = $Temp[3] &"/"& $Temp[2] &"/"& $Temp[1] msgbox(0,"",$Date) Link to comment Share on other sites More sharing options...
Developers Jos Posted August 21, 2006 Developers Share Posted August 21, 2006 why not do it the ease way when you want to convert it to the PC's Date/Time format ? #include<date.au3> $NewDate = _DateTimeFormat("2006/08/21 16:40:08",0) 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 More sharing options...
randallc Posted August 21, 2006 Share Posted August 21, 2006 Hi, Of course, if you are asking for your output in your local settings; $sDate="2006/08/21 16:40:08" MsgBox( 4096, "_DateTimeFormat ( $sDate, 0)=", ""&_DateTimeFormat ( $sDate, 0))If not, you'll have to parse. best, randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
iceberg Posted August 21, 2006 Author Share Posted August 21, 2006 (edited) thanks for all the replies guys. well here is what i wanna do actually....need BETA for this. expandcollapse popupAutoItSetOption("TrayIconHide", 1) #include <GUIConstants.au3> #include <File.au3> #include <Date.au3> $passwd = InputBox("Security Check - Login", "Please enter your password.", "", "x", 200, 130) If $passwd = ("password") Then $c1 = InputBox("Details", "Please Enter Your Name.") $c2 = InputBox("Details", "Please Enter Your Login ID.") If @error = 1 Then Exit $search = FileFindFirstFile("p*.txt") If $search = -1 Then MsgBox(16, "Error", "No files/directories matched the search pattern.") Exit EndIf $i = 0 $m = 0 $s = 0 While 1 SplashTextOn("", " Please wait . . . modifications in progress. " & @CRLF & @CRLF & "Number of files processed: " & $i, 260, 55, -1, -1, 3, "", 10) $file = FileFindNextFile($search) If @error Then ExitLoop $sNewDate1 = _DateAdd( 'n', $m, _NowCalc()) $sNewDate2 = _DateAdd( 's', $s, $sNewDate1) $val = _DateTimeFormat($sNewDate2, 3) _FileWriteToLine($file, 1, "Name: " & $c1, 1) _FileWriteToLine($file, 2, "Execution: " & _NowDate() & " " & $val, 1) _FileWriteToLine($file, 7, "Login: " & $c2, 1) FileSetTime("file pattern", "time", 0, 0); ???!!!THIS IS WHERE MY PROBLEM IS!!!??? $i = $i + 1 $m = $m + 3 $s = $s + 27 WEnd SplashOff() FileClose($search) MsgBox(0, "End", $i & " files have been modified successfully.") Exit Else MsgBox(16, "Warning!", "Login Failed - Access Denied") EndIf Line 39 gives me problem. Line 2 of the output text file must be in this format : "Execution: 8/21/2006 5:02:54 PM" I can get line 2 right. But I need the time in line 2 to be set as the FileSetTime (modified) for the files. Each file has a diff time in line 2 and therefore I also need the diff File Stamping times. I just can't work with this conversions. FileSetTime requires the format to be YYYYMMDDHHMMSS. Hence the problem, i think.... Please kindly assist. Thanks. Edited August 21, 2006 by iceberg mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
randallc Posted August 21, 2006 Share Posted August 21, 2006 Hi MsgBox(0,"","="&stringReplace(StringReplace(StringReplace("2006/08/21 16:40:08","/",""),":","")," ","")) Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
iceberg Posted August 21, 2006 Author Share Posted August 21, 2006 thanks for the reply randallc. but i m not too sure as what to do with your codes cos i am using variables _NowDate() & $val. thanks. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
randallc Posted August 21, 2006 Share Posted August 21, 2006 OK, Maybe; $val =StringReplace(StringReplace(_DateTimeFormat($sNewDate2, 2)& _DateTimeFormat($sNewDate2, 5),"/",""),":","") MsgBox(0,"","$val="&$val) FileSetTime($file,$val, 0, 0); ???!!!THIS IS WHERE MY PROBLEM IS!!!???Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
iceberg Posted August 21, 2006 Author Share Posted August 21, 2006 hi randall, using your latest codes, filesettime gives me wrong values. dates back to year 1617. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
randallc Posted August 21, 2006 Share Posted August 21, 2006 (edited) Hi,using your latest codes, filesettime gives me wrong values. dates back to year 1617.Strange. not for me.Oh, I see my error.. later sorryRandall Edited August 21, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
randallc Posted August 21, 2006 Share Posted August 21, 2006 Hi, maybe just; $val =StringReplace(StringReplace(StringReplace($sNewDate2,"/",""),":","")," ","")gives the $val setting to use in Filesettime. Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Recommended Posts