• 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: get seconds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get seconds


  • Subject: Re: get seconds
  • From: kai <email@hidden>
  • Date: Sun, 12 Oct 2003 12:58:32 +0100

on Sun, 12 Oct 2003 13:11:29 +0200, Patrick Mast wrote:

> how do i get the seconds from 1970 on?
>
> i wrote a script that is counting al the days an is then calculating
> the seconds.
>
> i saw a shell command <gettimeofday> but i do not succeed in getting
> the seconds back.
> it must be something like
>
> return do shell script "gettimeofday()"
>
> what parameters do i need for this command and how is it written
> properly? i do not really understand the man.

Plain ol' vanilla AppleScript should give you what you need, Patrick. Try
something like this:

------------------------------------------

set startDate to date "1/1/1970"
set secsElapsed to (current date) - startDate

------------------------------------------

To calculate other time units you could use AS constants:

------------------------------------------

set minsElapsed to secsElapsed div minutes
set hoursElapsed to secsElapsed div hours
set daysElapsed to secsElapsed div days
set weeksElapsed to secsElapsed div weeks

------------------------------------------

{secsElapsed, minsElapsed, hoursElapsed, daysElapsed, weeksElapsed}

--> {1.065963415E+9, 17766056, 296100, 12337, 1762}

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

  • Prev by Date: get seconds
  • Next by Date: Re: How do I format a number or Round a number?
  • Previous by thread: get seconds
  • Next by thread: Re: get seconds
  • Index(es):
    • Date
    • Thread