From owner-freebsd-questions@FreeBSD.ORG Sun Nov 28 12:09:59 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 8D6D416A4CE for ; Sun, 28 Nov 2004 12:09:59 +0000 (GMT) Received: from s22.loopia.se (s22.loopia.se [194.9.95.5]) by mx1.FreeBSD.org (Postfix) with SMTP id 8BBE543D31 for ; Sun, 28 Nov 2004 12:09:58 +0000 (GMT) (envelope-from jimmy.makela@loopia.se) Received: (qmail 99079 invoked from network); 28 Nov 2004 12:09:56 -0000 Received: from unknown (HELO i11) (194.9.94.253) by 194.9.95.5 with SMTP; 28 Nov 2004 12:09:56 -0000 Message-ID: <045701c4d543$2ff2c160$c600a8c0@i11> From: =?iso-8859-1?Q?Jimmy_M=E4kel=E4_|_Loopia_Webbhotell_AB?= To: Date: Sun, 28 Nov 2004 13:10:01 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Subject: 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 12:09:59 -0000 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ä