formatDate("Y-m-d", current date)
on formatDate(theFormat, theDate)
-- theDate should be an AppleScript date object
do shell script "/usr/bin/php -r 'echo date($argv[1], strtotime($argv[2]));' " & ¬
quoted form of theFormat & " " & quoted form of (theDate as Unicode text)
end formatDate
formatDate("%Y-%m-%d", current date)
on formatDate(theFormat, theDate)
-- theDate should be an AppleScript date object
try
do shell script "/usr/bin/ruby -e 'require \"parsedate\"; puts Time.local(*ParseDate.parsedate(ARGV[1])).strftime(ARGV[0])' " & ¬
quoted form of theFormat & " " & quoted form of (theDate as Unicode text)
on error
-- The date could not be parsed
return false
end try
end formatDate
formatDate("Y-m-d", (current date) as «class isot» as string)
on formatDate(theFormat, theDate)
-- Example for theDate: "2007-10-23T17:54:23"
do shell script "/usr/bin/php -r 'echo date($argv[1], strtotime($argv[2]));' " & ¬
quoted form of theFormat & " " & quoted form of theDate
end formatDate
formatDate("%Y-%m-%d", (current date) as «class isot» as string)
on formatDate(theFormat, theDate)
-- Example for `theDate`: "2007-10-23T17:54:23"
try
do shell script "/usr/bin/ruby -e 'require \"parsedate\"; puts Time.local(*ParseDate.parsedate(ARGV[1])).strftime(ARGV[0])' " & ¬
quoted form of theFormat & " " & quoted form of theDate
on error
-- The date could not be parsed
return false
end try
end formatDate
formatDate("Y-m-d_H-i-s", current date)
on formatDate(F, D)
tell D as «class isot» as string to set theDate to text 1 thru 10 & " " & text 12 thru -1
do shell script "/usr/bin/php -r 'echo date($argv[1], strtotime($argv[2]));' " & ¬
quoted form of F & " " & quoted form of theDate
end formatDate