• 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: Getting time components of date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting time components of date


  • Subject: Re: Getting time components of date
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 22 Dec 2003 08:54:02 -0600

At 07:59 -0500 12/22/2003, Chris Garaffa wrought:

While working to convert an AppleScript date to a MySQL DATETIME date (yyyy-mm-dd hh:mm:ss) I ran into a small problem. While AppleScript supports things like:
______________________________________________________________________

Hello Chris,

This is very dependent upon your international settings and requires Panther for the "short date string".

set d1 to current date
set ts to time string of d1

--> 07:55:29

set sds to short date string of d1

--> 12/22/2003

set AppleScript's text item delimiters to {"/"}
set sqlDate to (reverse of (text items of sds))
set AppleScript's text item delimiters to {"-"}
set sqlDate to (sqlDate as string) & " " & ts

--> 2003-22-12 08:09:43

Arthur Knapp posted a excellent and fast (if large) handler for getting most any date format based upon a given date and a format string (message me privately if you want it).

The simplest method on Mac OS X is to use a shell script, although various AppleScript methods are a faster.

set sqlDate to do shell script "date +'%Y-%M-%d %T'"

--> 2003-41-22 08:41:18

Use "man strftime" in the terminal to discover all the metacharacters.


Chris
_______________________________________________
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.

References: 
 >Getting time components of date (From: Chris Garaffa <email@hidden>)

  • Prev by Date: Re: OT: "Reply to all" oddity; server or Entourage??
  • Next by Date: Re: Panther bug: "Volumes" folder not updating
  • Previous by thread: Getting time components of date
  • Next by thread: Re: Getting time components of date
  • Index(es):
    • Date
    • Thread