From owner-freebsd-questions@FreeBSD.ORG Wed Jun 20 21:32:08 2007 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0CDA616A41F for ; Wed, 20 Jun 2007 21:32:08 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id C207713C4C5 for ; Wed, 20 Jun 2007 21:32:07 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.1/8.13.8) id l5KLW2X2024077; Wed, 20 Jun 2007 16:32:02 -0500 (CDT) (envelope-from dan) Date: Wed, 20 Jun 2007 16:32:02 -0500 From: Dan Nelson To: Gore Jarold Message-ID: <20070620213202.GQ94657@dan.emsphone.com> References: <925700.29847.qm@web63015.mail.re1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <925700.29847.qm@web63015.mail.re1.yahoo.com> X-OS: FreeBSD 6.2-STABLE User-Agent: Mutt/1.5.15 (2007-04-06) Cc: questions@freebsd.org Subject: Re: freebsd version of 'data' for getting epoch time ... ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2007 21:32:08 -0000 In the last episode (Jun 20), Gore Jarold said: > If I have a arbitrary date/time and I want to convert > that to epoch time, I do this with GNU date: > > date --date='1970-01-01 00:02:00 +0000' +%s > > Easy. > > Can someone tell me what the syntax is for FreeBSD > date command ? date -j -f '%Y-%m-%d %H:%M:%S %Z' '1970-01-01 00:02:00 GMT' +%s Adjust the -f argument to match whatever format your input string has (the date manpage has an example that parses date's default output back into itself). Unfortunately, it looks like strptime doesn't handle the %z flag, which is why I changed your +0000 to GMT and used %Z instead. %z is actually easier to parse, so I'm not sure why it's not handled. -- Dan Nelson dnelson@allantgroup.com