Zsh Mailing List Archive
Messages sorted by:
Convert UTC time to local time using strftime and zsh/datetime
- X-seq: zsh-users 19881
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: Zsh-Users List <zsh-users@xxxxxxx>
- Subject: Convert UTC time to local time using strftime and zsh/datetime
- Date: Fri, 20 Feb 2015 23:41:24 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=TyGFtuYL6xJ5wtESgivGQLCIUXdR6im+PZPtFzC0vVk=; b=nW2Xx9Fadbul3Mrc0SVuASASu73FZpz+/krKAPIfd/aWoieu7S4scnnxHmu0g7+Xhv nH1E60WJAJ+zOWW6XG4slIaahYxwPlVxvkHYtLKtNPglgd47fJEHXAf8EmV45CxtzrPh 6zTnpitSRhtYU6p9GXk24HjgzCtSh1xU/m59HeRMK/CPZNGJ7vKQGmCD9ef1xCB55FEB 5nXErpiaCftwebpGwoD7WKCuDLQocMEfBJ+3m4FJTIRVuLKKyR+XrFTz8ktHe5XbnglQ NArlKctKHoKZZMMuyt4Dx4dPLPMmxzyZk2DDf1qaaowN0pALQM4nvcbiXZUT1zmXfnd+ nGiw==
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
I have a screenshot of my iPhone which shows that it was taken at 11:42 a.m.
When I look at the file in Finder, it shows that it was taken at 11:42 a.m.
on Feb 11
You can see a screenshot here:
When I use `mdls -raw -name kMDItemContentCreationDate test.png` (a Mac
command to get the Creation Date), I get
2015-02-11 16:42:30 +0000
as the answer. This is, I believe, UTC. So I need to convert that to local
I'm not sure how to do that, so heres what I did
1) Load the appropriate module
> zmodload zsh/datetime
2) get the Unix EPOCH time from the date/time stamp we have:
> strftime -r "%Y-%m-%d %H:%M:%S +0000" "2015-02-11 16:42:30 +0000"
3) Convert '1423690950' to US/Eastern time:
> strftime "%Y-%m-%d %H:%M:%S" "1423690950"
But that's still giving me '16' as the hour. It should be 11, shouldn't it?
4) Try again, this time making sure that I define the time zone:
> TZ=US/Eastern strftime "%Y-%m-%d %H:%M:%S" "1423690950"
OK, so I'm obviously missing something. I checked '1423690950' on various
online "Unix time" converters and they confirm that it's 16:42 my time, but
since I know the picture was taken at 11:42, I'm wondering what I did wrong.
Messages sorted by: