• 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
Specific Date-Time Formatting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Specific Date-Time Formatting


  • Subject: Specific Date-Time Formatting
  • From: Chris Tangora <email@hidden>
  • Date: Thu, 3 Nov 2005 12:06:33 -0500

Hi All, I found this in the archive and wanted to know if there was an option to get the date from two days in the future.  I'm trying to make script that will look ahead for what the month and day will be in numerical format.  I'm using the shell script "date" to get the current date, but I want to get that same info as + 2 days.

Does anybody know how to do this?   I like the terminal / shell options rather than changing the text item delimiters, sorting out, etc.  But you gotta work with what you have.

Any advice is apperciated!


Chris



On May 26, 2005, at 6:00 PM, Mark J. Reed wrote:

What Gnarlie said.  The UNIX date(1) command's time-formatting feature lets you do whatever you want, even if the field keys are a little cryptic.  You can get a full list by typing "man date" or "man strftime" in a terminal window, but here are the basics.

set formattedDateString to (do shell script "date +'...format string goes here...'")

where format string can include anything you like, with placeholders for the parts to be replaced by the date values:

%% to get a literal percent sign if you need one

%y to get the two-digit year
%Y to get the four-digit year

%m to get the month number (1-12)
%b to get the short month name (Jan, Feb, Mar,... in English)
%B to get the long month name (January, February, March,... in English)

%d to get the day of the month (1-31)

%H to get the hour in 24-hour time (0-23)
%I to get the hour in 12-hour time (1-12)
%p to get an AM/PM indicator to go with %I

%M to get the minute of the hour

%S to get the second of the minute

%Z to get the time zone label

If you want to throw in the weekday, it's %a for the short name (Sun, Mon, Tue...
in English) and %A for the long name (Sunday, Monday, Tuesday,... in English).

So if you want yyyy/mm/dd it's

do shell script "date +'%Y/%m/%d'"



On 5/26/05, Gnarlodious <email@hidden> wrote:
Entity Jack Stewart spoke thus:

>  mm/dd/yyyy date format plus the time-of-day

do shell script "date '+%m/%d/%y@%I:%M:%S %p' "


-- Gnarlie


Chris Tangora
Daytona Beach News-Journal
386.681.2748
chris.tangora <at> news-jrnl <dot> com



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Specific Date-Time Formatting
      • From: "Mark J. Reed" <email@hidden>
    • Re: Specific Date-Time Formatting
      • From: Dave Lyons <email@hidden>
  • Prev by Date: Re: Reloading PDF-document in Preview using AppleScript
  • Next by Date: Re: SSH security question... Please comment my thoughts...
  • Previous by thread: Re: Records
  • Next by thread: Re: Specific Date-Time Formatting
  • Index(es):
    • Date
    • Thread