954,160 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

date command

HI Guys,

Prob a very simple one but im stumped, I run the following command and get:

date
Wednesday, 19 August 2009 09:20:59 BST

But when I run

date -u '+%y%m%d.%H:%M:%S'
090819.08:21:27


My question is why is the second command an hour behind? In my environment the following are set:

LC_TIME=en_GB.ISO8859-15
TZ=GB

I have tried it on a different server with exactly the same commands and env variables and get the correct result, what am I doing wrong here?

chris5126
Posting Pro in Training
415 posts since Feb 2006
Reputation Points: 38
Solved Threads: 15
 

Great Britian has summer daylight savings time which means your clock is off by an hour.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

hi,

But why does the date command give me the correct date then when I try and use the date -u command does it suddenly consider day light savings?

chris5126
Posting Pro in Training
415 posts since Feb 2006
Reputation Points: 38
Solved Threads: 15
 

Please see this site:
http://wwp.greenwichmeantime.com/

It doesn't make sense to me either but it seems like that is probably a law in GB.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

I have worked it out have used:

`date +"%Y.%m.%d.%H%M"`

Instead of date -u

chris5126
Posting Pro in Training
415 posts since Feb 2006
Reputation Points: 38
Solved Threads: 15
 

Actually, the below command gives the time as per GMT :

date -u


where as on using

date


, we get the time according to what we have set our time zone (TZ) as.

iceman29
Newbie Poster
12 posts since Feb 2008
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You