1

I used to have a AppleScript snippet which convert my date to this format : 08/25/2017 (MM/DD/YY) The source date format changed and I don't managed to make it work

e.g :

set creationDate to "2013-04-03"



set [M, ordinal, Y] to the words of creationDate

set the text item delimiters to {"st", "nd", "rd", "th"}
set cardinal to (first text item of ordinal) --> "2"
set cardinal to text -1 thru -2 of ("0" & cardinal) --> "02"

set the text item delimiters to space
set date_string to {M, cardinal, Y} as text

-- date -j -f '%B %d %Y' 'June 02 2012' +'%d/%m/%Y'
set command to {¬
    "date -j -f '%B %d %Y'", ¬
    quoted form of the date_string, ¬
    "+'%d/%m/%Y'"}

The creation date is an example but it's taken from a webpage and it's not fix.

here the result I received

{"date -j -f '%B %d %Y'", "'2013 04 03'", "+'%d/%m/%Y'"}

  • Your example of creationDate is ambiguous. Is it year then month then day or year then month then day. – Tony Williams Apr 27 '18 at 5:42
1

If your example is in the order year, day, month and you want MM/DD/YYYY then this code does the job

set creationDate to "2013-04-03"
set [Y, ordinal, M] to the words of creationDate
set the text item delimiters to "/"
set date_string to {M, ordinal, Y} as text

What you are attempting to do with the date command is unclear.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .