How to set a date format using AppleScript?

Hi! I would like to know if is it possible to set a format like “Thu, 18 Aug 2005 21:30:34 CEST”. Only I can set the format like : “Thursday, 18 August 2005 21:30:34”. The first format is important to generate my RSS. Anybody can help me? Thanks in advance!
Alex

Hi Alex,

There’ll be a lot of ways of doing this. The script below is over several lines to show you each step. You could make it into one (long) line of script. Are you starting with a date variable or a text variable?

-- To get "Thu, 18 Aug 2005 21:30:34 CEST"
--Not tested
set myString to "Thursday, 18 August 2005 21:30:34"
set shortDay to (characters 1 thru 3 of (word 1 of myString)) as text
set theDate to word 2 of myString
set shortMonth to (characters 1 thru 3 of (word 3 of myString)) as text
set theYear to word 4 of myString
set theTime to (word 5 of myString) & ":" & (word 6 of myString) & ":" & (word 7 of myString) 
set localZone to "CEST"
set myRFC822date to (shortDay & ", " & theDate & " " shortMonth & " " & theYear & " " & theTime & " " & localZone) as text

Best wishes

John M

--set short_time to do shell script "date | awk '{ print $1\",\", $2, $6, $4, $5}'" --pre10.4
set short_time to do shell script "date | awk '{ print $1" & quote & "," & quote & ", $2, $6, $4, $5}'" --10.4.x

It works, John M! Thank You! Only one thing: writing it you forgot “&” before shortMonth:
Now, I tested it and it works perfectly:


set myString to "Thursday, 18 August 2005 21:30:34"
set shortDay to (characters 1 thru 3 of (word 1 of myString)) as text
set theDate to word 2 of myString
set shortMonth to (characters 1 thru 3 of (word 3 of myString)) as text
set theYear to word 4 of myString
set theTime to (word 5 of myString) & ":" & (word 6 of myString) & ":" & (word 7 of myString)
set localZone to "CEST"
set myRFC822date to (shortDay & ", " & theDate & " " & shortMonth & " " & theYear & " " & theTime & " " & localZone) as text

Thanks!
Alex