From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9767 invoked by alias); 21 Feb 2015 04:42:14 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19881 Received: (qmail 335 invoked from network); 21 Feb 2015 04:42:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 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== X-Received: by 10.50.43.169 with SMTP id x9mr876368igl.28.1424493725258; Fri, 20 Feb 2015 20:42:05 -0800 (PST) MIME-Version: 1.0 From: TJ Luoma Date: Fri, 20 Feb 2015 23:41:24 -0500 Message-ID: Subject: Convert UTC time to local time using strftime and zsh/datetime To: Zsh-Users List Content-Type: multipart/alternative; boundary=089e01184b9a7a994f050f91caf6 --089e01184b9a7a994f050f91caf6 Content-Type: text/plain; charset=UTF-8 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: http://images.luo.ma/skitch/iPhonePhotos-1142am-20150220-231455.jpg 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 (US/Eastern) time. 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" 1423690950 3) Convert '1423690950' to US/Eastern time: > strftime "%Y-%m-%d %H:%M:%S" "1423690950" 2015-02-11 16:42:30 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" 2015-02-11 16:42:30 Same time. 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. Tj --089e01184b9a7a994f050f91caf6--