From owner-freebsd-questions@FreeBSD.ORG Sun Nov 28 18:10:28 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2860216A4CE for ; Sun, 28 Nov 2004 18:10:28 +0000 (GMT) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by mx1.FreeBSD.org (Postfix) with ESMTP id 952FC43D45 for ; Sun, 28 Nov 2004 18:10:27 +0000 (GMT) (envelope-from aeder@list.ru) Received: from [82.179.204.50] (port=63459 helo=gateway.my.home) by mx1.mail.ru with esmtp id 1CYTVC-000Lup-00; Sun, 28 Nov 2004 21:10:26 +0300 Received: from [10.0.1.5] (megagame.my.home [10.0.1.5]) by gateway.my.home (8.12.6/8.12.6) with ESMTP id iASIAPeK000894; Sun, 28 Nov 2004 21:10:25 +0300 (MSK) (envelope-from aeder@list.ru) Message-ID: <41AA14D4.608@list.ru> Date: Sun, 28 Nov 2004 21:11:32 +0300 From: =?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCU0LXRgNC10LLRj9C90LrQvg==?= User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?UTF-8?B?SmltbXkgTcOka2Vsw6QgfCBMb29waWEgV2ViYmhvdGVsbCBBQg==?= References: <045701c4d543$2ff2c160$c600a8c0@i11> In-Reply-To: <045701c4d543$2ff2c160$c600a8c0@i11> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam: Not detected cc: freebsd-questions@freebsd.org Subject: Re: Timezone conversion X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Nov 2004 18:10:28 -0000 Jimmy Mäkelä | Loopia Webbhotell AB wrote: > Hi > > I'm trying to convert a date from one timezone into another using the > date-command, but I can't seem to get it to work. > > The problem can be illustrated as below, though in reality I get the > date from another source of course, otherwise I wouldn't have to do this. > > Take a date in some timezone other than your own, in this example I > generate the current time in UTC: > >> TZ=UTC date +"%d %b %Y %H:%M:%S %z" > > 28 Nov 2004 12:02:18 +0000 > > Try to use date -j to convert a date of this format into the default > display-format: > >> TZ=CET date -j -f "%d %b %Y %H:%M:%S %z" "28 Nov 2004 12:02:18 +0000" > > Warning: Ignoring 5 extraneous characters in date string (+0000) > Sun Nov 28 12:02:18 CET 2004 > > The result is wrong of course because the timezone is ignored even > though i specify %z in the format-string. The date in CET should be > 13:02:18. > > Now the question; does anyone know why the %z is ignored? Am I missing > something, and if so what? > > The man-page for the -f parameter states "Parsing is done using > strptime(3)." and since strptime allows %z I was assuming that the > example above should work. > > I would be really thankful for some help in getting around this. > > Thanks in advance. > > Best regards, > Jimmy Mäkelä > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" > > Try the following: 1. Output date in seconds from epoch SECONDS=$(date ... "+%s") 2. Change the time zone. TZ=CET export TZ date -r $SECONDS Best regards, Alexander Derevianko.