Re: [CentOS] Date question

2021-02-18 Thread Jerry Geis
On Wed, Feb 17, 2021 at 1:57 PM Jerry Geis  wrote:

> SO from the man page on date I can do
>
> current=`TZ=":America/Indianapolis" date`
> echo $current
> current=`TZ=":America/Los_Angeles" date `
> echo $current
>
> And I get correct data. LA is 3 hours earlier.  But doing this:
>
> current=`TZ=":America/Indianapolis" date +%s`
> echo $current
> current=`TZ=":America/Los_Angeles" date +%s`
> echo $current
>
> I get the same data - its not 3 hours different.
>
> What am I not doing correct ?
>
> Thanks,
>
> Jerry
>


Hi All - I did figure this out. I was close the first time - but just not
right.

FROM_DATE_TIME=`TZ="America/Los_Angeles" date --date '120 sec ago'
+'%Y-%m-%d %H:%M:%S'`
TO_DATE_TIME=`TZ="$America/Los_Angeles" date --date '1 sec ago' +'%Y-%m-%d
%H:%M:%S'`

and my server is set for Indianapolis time. The above worked.
Thanks!

Jerry
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Date question

2021-02-17 Thread Jonathan Billings
On Wed, Feb 17, 2021 at 01:57:50PM -0500, Jerry Geis wrote:
>
> SO from the man page on date I can do
> 
> current=`TZ=":America/Indianapolis" date`
> echo $current
> current=`TZ=":America/Los_Angeles" date `
> echo $current
> 
> And I get correct data. LA is 3 hours earlier.  But doing this:
> 
> current=`TZ=":America/Indianapolis" date +%s`
> echo $current
> current=`TZ=":America/Los_Angeles" date +%s`
> echo $current
> 
> I get the same data - its not 3 hours different.
> 
> What am I not doing correct ?

Check the man page for 'date'.

%s is "seconds since 1970-01-01 00:00:00 UTC".  Regardless of the time
zone, the time in LA will still be the same number of seconds since
Midnight, January 1st, 1970 in UTC as it was in Indianapolis. 
-- 
Jonathan Billings 
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Date question

2021-02-17 Thread Chris Schanzle via CentOS
On 2/17/21 1:57 PM, Jerry Geis wrote:
> SO from the man page on date I can do
>
> current=`TZ=":America/Indianapolis" date`
> echo $current
> current=`TZ=":America/Los_Angeles" date `
> echo $current
>
> And I get correct data. LA is 3 hours earlier.  But doing this:
>
> current=`TZ=":America/Indianapolis" date +%s`
> echo $current
> current=`TZ=":America/Los_Angeles" date +%s`
> echo $current
>
> I get the same data - its not 3 hours different.
>
> What am I not doing correct ?
>
> Thanks,
>
> Jerry

Per the date(1) man page,

   %s seconds since 1970-01-01 00:00:00 UTC

Thus,%s is independent of the timezonerelative to UTC.

And you don't need any of those double-quotes.

___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


[CentOS] Date question

2021-02-17 Thread Jerry Geis
SO from the man page on date I can do

current=`TZ=":America/Indianapolis" date`
echo $current
current=`TZ=":America/Los_Angeles" date `
echo $current

And I get correct data. LA is 3 hours earlier.  But doing this:

current=`TZ=":America/Indianapolis" date +%s`
echo $current
current=`TZ=":America/Los_Angeles" date +%s`
echo $current

I get the same data - its not 3 hours different.

What am I not doing correct ?

Thanks,

Jerry
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos