Date: Sun, 28 Nov 2004 21:11:32 +0300 From: =?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCU0LXRgNC10LLRj9C90LrQvg==?= <aeder@list.ru> To: =?UTF-8?B?SmltbXkgTcOka2Vsw6QgfCBMb29waWEgV2ViYmhvdGVsbCBBQg==?= <jimmy.makela@loopia.se> Cc: freebsd-questions@freebsd.org Subject: Re: Timezone conversion Message-ID: <41AA14D4.608@list.ru> In-Reply-To: <045701c4d543$2ff2c160$c600a8c0@i11> References: <045701c4d543$2ff2c160$c600a8c0@i11>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41AA14D4.608>