Jump to content

Recommended Posts

Posted

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.

Posted (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 by Rad
Posted (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 :P. Edited by Larry

qq

Posted

Oh yea string split sounds better

$date = "2006/08/21"
$temp = StringSplit($date,"/")
$Date = $Temp[3] &"/"& $Temp[2] &"/"& $Temp[1]
msgbox(0,"",$Date)
Posted (edited)

thanks for all the replies guys.

well here is what i wanna do actually....need BETA for this.

AutoItSetOption("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 by iceberg

mouse not found....scroll any mouse to continue.

Posted

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.

Posted

hi randall,

using your latest codes, filesettime gives me wrong values. dates back to year 1617.

mouse not found....scroll any mouse to continue.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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