convert
container from
format and
format to
format and
format
Format is one of the following: date
, short date
, abbreviated date
, long date
, English date
, short time
, abbreviated time
, long time
, English time
, seconds
, or dateItems
.
convert line 1 of steve from date to dateItems
convert bill from date and time to dateItems
convert andy to seconds
convert first line of steve to long date and short time
The convert
command gets a date or time and converts it from a particular format, if specified, to a particular format. This command works with either the local date format or the U.S. date format.
If the first parameter to the convert
command is a container, the converted date or time is placed in that container. If the first parameter is not a container, the converted date or time is placed in the local variable it
.
A script that needs to work with dates and times should convert them to the seconds
or dateItems
format before working on them. This avoids problems that may occur when running the script in a different locale. The seconds
and dateItems
formats are the only ones guaranteed to be recognized in any locale.
The following example prints tomorrow's date in the short format regardless of the current locale:
on printTomorrow get the date convert it to dateItems add 1 to item 3 of it convert it to short date put it end printTomorrow