coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug or feature - converting date and timestamps


From: Calin Giurgiu, Mr.
Subject: Bug or feature - converting date and timestamps
Date: Wed, 6 Nov 2024 17:33:44 +0000

Hi,

Please review the below commands and at least let me know if this is a bug or a 
feature (of which logic I am not aware):

localuser@datamap:~$ timestamp="2024-10-17 02:40:00"

localuser@datamap:~$ utc_timestamp=$(date -d "$timestamp +4 hours" +"%Y-%m-%d 
%H:%M:%S")
localuser@datamap:~$ echo $utc_timestamp
2024-10-16 19:40:00

localuser@datamap:~$ utc_timestamp=$(date -d "$timestamp 4 hours" +"%Y-%m-%d 
%H:%M:%S")
localuser@datamap:~$ echo $utc_timestamp
2024-10-17 06:40:00

localuser@datamap:~$ utc_timestamp=$(date -d "$timestamp -4 hours" +"%Y-%m-%d 
%H:%M:%S")
localuser@datamap:~$ echo $utc_timestamp
2024-10-17 03:40:00

The expected behavior is accomplished only when not using +/- . But then one 
would wonder how to go about substracting 4 hours from the time stamp?

This anomaly was encountered in both Ubuntu and RHEL flavors:

apt show coreutils
Package: coreutils
Version: 8.32-4.1ubuntu1.2


yum list installed coreutils
coreutils.x86_64                                                           
8.22-24.el7_9.2

Any response would be much appreciated.

Calin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]