Re: Epoch Seconds to YYYY-MM-DD
Re: Epoch Seconds to YYYY-MM-DD
- Subject: Re: Epoch Seconds to YYYY-MM-DD
- From: Christopher Stone <email@hidden>
- Date: Sat, 27 Apr 2013 14:26:36 -0500
On Apr 27, 2013, at 11:00, Marconi <email@hidden> wrote:
>> If you pass it as a string it should work fine:
> But I'm not; I'm calculating it.
>
> -- Find epoch seconds for today's date
>
> set TodaySeconds to do shell script "date -j -f \"%a %b %d %T %Z %Y\" \"`date`\" \"+%s\""
>
> set epochseconds to (TodaySeconds - (3 * 86400))
______________________________________________________________________
Hey Marconi,
If all you're doing is shifting by days you can do that with 'date' from the shell:
This one relies on your input string format of course:
date -v -3d -jf "%a %b %d %T %Z %Y" "`date`" "+%Y-%m-%d %H:%M:%S"
do shell script "date -v -3d -jf \"%a %b %d %T %Z %Y\" \"`date`\" \"+%Y-%m-%d %H:%M:%S\""
OR just the plain current date shifted backwards by 3 days:
date -v -3d -j "+%Y-%m-%d %H:%M:%S"
do shell script "date -v -3d -j \"+%Y-%m-%d %H:%M:%S\""
Look under 'Adjust' in the 'date' man page.
For other calculations you may want to scope out 'bc' in the shell.
echo "1367090450 - (3 * 86400)" | bc
--
Best Regards,
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden