Skip to content

Instantly share code, notes, and snippets.

@ROldford
Created July 6, 2013 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ROldford/5941583 to your computer and use it in GitHub Desktop.
Save ROldford/5941583 to your computer and use it in GitHub Desktop.
Applescript method for creating time stamps. Great for use with filenames! Adapted from MacScripter (http://macscripter.net/viewtopic.php?id=24737)
to timeStamp(theDate) -- theDate must be date object
set separator to "-" -- can be changed to whatever you prefer
set y to year of theDate
set m to month of theDate
set d to day of theDate
set t to time of theDate
set dateNumber to (y * 10000 + m * 100 + d)
set tempDateString to dateNumber as string
set dateString to text 1 thru 4 of tempDateString & separator & text 5 thru 6 of tempDateString & separator & text 7 thru 8 of tempDateString & separator & t
return dateString
end timeStamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment