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Ã

_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"




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.
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"
  • ... ÐÐÐÐÑÐÐÐÑ ÐÐÑÐÐÑÐÐÐ

Reply via email to