Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have problem with unix timestamp ( date +%s ). This command gives me a GMT time, however I am using CET, so the unix timestamp is in 1 hour late (and my rrdtool database too!). How I can change unix timestamp's to CET or add +1 hour?

With command "date" I get good time. Update:

@ubuntu:~/tmp$ date +%s%Z
1295915413CET
@ubuntu:~/tmp$ cat /etc/timezone
Europe/Bratislava
@ubuntu:~/tmp$ date
Tue Jan 25 01:30:28 CET 2011
@ubuntu:~/tmp$ date +%s
1295915459
@ubuntu:~/tmp$ in normal time: Tue, 25 Jan 2011 00:30:13 GMT

Update2:

In online converters I can set the timezone, so maybe the numbers are equal for all timezone? Then the question is that, why rrdtools late a hour?

@ubuntu:~/tmp$ date -d @1295916112 Tue Jan 25 01:41:52 CET 2011

As we can see the timestamp is correct, only rrdtool is wrong. But why?

share|improve this question
    
We don't delete questions that could be of benefit to someone else later. Please roll back your edit. Especially so people can see what the actual solution is. –  Dennis Williamson Jan 25 '11 at 1:21
add comment

2 Answers

up vote 0 down vote accepted

That's odd. On my Ubuntu Linux system I get unix time in CET when I enter date +%s.

Could you show us the output of date +%s%Z? And could you cat /etc/timezone?

share|improve this answer
1  
That's odd, date %s shows me a number of seconds without a time zone. –  Dennis Williamson Jan 25 '11 at 0:28
    
I updated my question. –  user66638 Jan 25 '11 at 0:35
add comment

That's what %s is supposed to do. From man date:

%s     seconds since 1970-01-01 00:00:00 UTC
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.