I'm extracting different date formats from a web page.
E.g. Sunday 10 September 2017 / 09/10/2017 / September 10th, 2017.
in the example the date is the same, but in live, the dates are
completely random and different. This could be 01/2/1985 / November
10th, 2005
The first one doesn't matter too much as this is the current date, which I'm generating myself and I can change it:
tell (current date)
set strMonth to (its month as integer)
set strDay to (its day as integer)
set stryear to (its year as integer)
end tell
set myOwnDate to strMonth & "/" & strDay & "/" & stryear as string
The format I want is integer day/month/year so 10/09/2017.
Can I change the two other strings (09/10/2017 / September 10th, 2017) to this format?
Best Answer
You can use the NSDataDetector (a cocoa method) for parsing date from a string.
Here's the script (tested on macOS Sierra):
Warning: on a string which contains "digit/digit/year", the script does not work with a string in the "day/month/year" format, the string must be in the "month/day/year" format