• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: numeric date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: numeric date


  • Subject: Re: numeric date
  • From: Tony Wilson <email@hidden>
  • Date: Sat, 19 Jul 2003 14:17:55 -0500

"I need to convert the month from the current date to a 2-digit number. My purpose is to make a folder name, like 2003.07.19"

do shell script "date +%Y.%m.%d"
-->"2003.07.19"

%% a '%' character
%a abbreviated weekday name
%A full weekday name
%b abbreviated month name
%B full month name
%c a system date representation
%d day of the month as a decimal number (01-31)
%e same as %d but does not print the leading 0 for days 1 through 9
%H hour based on a 24-hour clock as a decimal number (00-23)
%I hour based on a 12-hour clock as a decimal number (01-12)
%j day of the year as a decimal number (001-366)
%m month as a decimal number (01-12)
%M minute as a decimal number (00-59)
%p AM/PM designation for the locale
%S second as a decimal number (00-59)
%w weekday as a decimal number (0-6), where Sunday is 0
%x date using the date representation for the locale
%X time using the time representation for the locale
%y year without century (00-99)
%Y year with century (such as 1990)
%Z time zone name (such as Pacific Daylight Time)
%z time zone offset in hours and minutes from GMT (HHMM)


The unix cal command can also come in handy for certain 'date' scripting tasks:

set monthCount to word -1 of (do shell script "cal")
-->"31"
set febCount to word -1 of (do shell script "cal 2 2003") as number
-->28

--If your looping thru every day of the month (to build urls for an example):

set dayList to words 10 thru -1 of (do shell script "cal")
-->{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: numeric date
      • From: email@hidden
References: 
 >numeric date (From: email@hidden)

  • Prev by Date: Re: My apologies
  • Next by Date: Re: OS version questions
  • Previous by thread: Re: numeric date
  • Next by thread: Re: numeric date
  • Index(es):
    • Date
    • Thread