LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 03-31-2015, 06:45 PM   #1
subhajitlinuxfreak
LQ Newbie
 
Registered: Mar 2015
Posts: 3

Rep: Reputation: Disabled
Unhappy Unix timestamp anomaly


Hi,

I am seriously puzzled by seeing the below anomaly:
When I want to fetch 7 days ago date at around 12:48 AM on April 1 it is displaying the date as 24th March which is wrong (should be Mar 25).
Again when I am issuing the same expression at around 1:15 AM on the same day i.e. Apr 1 it is displaying correctly as Mar 25. Point to be noted that my Linux box is following CEST timezone and on Mar 29th out ntp server changed to DST timings.Attached are the commands and results I executed and obtained.

Thanks in advance,
Subhajit

-bash-4.1$ echo $(date +"%Y-%m-%d" --date="7 days ago")
2015-03-24

-bash-4.1$ echo $(date)
Wed Apr 1 00:48:36 CEST 2015

---------------------------------------------------------------------------

-bash-4.1$ echo $(date +"%Y-%m-%d" --date="7 days ago")
2015-03-25

-bash-4.1$ date
Wed Apr 1 01:15:35 CEST 2015


I am using RedHat Linux 6 version
 
Old 03-31-2015, 09:48 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,676

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
If you output the time and date you will find that Wed Apr 1 00:48:36 CEST 2015 7 days ago is actually 7 days minus an hour which makes it the 24th.

For your information ntp does not care about time zones or DST. It only works on UTC.

Last edited by michaelk; 03-31-2015 at 09:50 PM.
 
Old 04-03-2015, 10:02 AM   #3
subhajitlinuxfreak
LQ Newbie
 
Registered: Mar 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Unhappy Doubt still remains

Thanks Michael for your reply.
But the question remains as to why "minus one hour" that you mentioned in your reply?
Ideally, it should be 25th right?

Thanks in advance,
Subhajit
 
Old 04-03-2015, 10:14 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,676

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Because the date command corrects for time changes.
 
Old 04-03-2015, 10:30 AM   #5
subhajitlinuxfreak
LQ Newbie
 
Registered: Mar 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Smile Thank you

Thanks for the explanation Michael.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Anomaly Defenders Released For Linux, The Last In The Anomaly Series LXer Syndicated Linux News 0 05-31-2014 03:02 AM
How to get date from unix timestamp ruj.sabya Linux - General 9 03-22-2007 05:59 PM
Unix Timestamp Nargile Linux - Software 1 03-17-2005 09:07 PM
unix timestamp (squid) eduac Linux - Security 3 02-16-2005 02:03 AM
unix/linux timestamp sopiaz57 Linux - Security 3 06-16-2003 09:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 07:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration