I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- convert an AppleScript Date object to a POSIX date CCYYMMDDHHmm.SS | |
on posixDate(datetime) | |
-- date -j -f "%A, %B %e, %Y at %I:%M:%S %p" "Tuesday, September 1, 2015 at 11:00:00 AM" +%Y%m%d%H%M | |
set command to "date -j -f '%A, %B %e, %Y at %I:%M:%S %p' '" & datetime & "'" | |
set command to command & " +%Y%m%d%H%M.%S" | |
set thePosixDate to do shell script command | |
return thePosixDate | |
end posixDate |