Score:-3

Time not utc linux

mr flag

How can I get my local time by pulling information from the Internet without using utc time?

When I run the command below it will always return the time in utc format...

curl -I ' https://google.com/ ' 2>/dev/null | grep -i '^date:' | sed 's/^[Dd]ate: //g'

I would just like it to show the result in my local time and not with utc.

Jaromanda X avatar
ru flag
well, you can't tell google what to return - and I believe headers always use GMT/UTC anyway ... are you perhaps asking how to convert UTC time string into your local time?
Luana avatar
mr flag
that's right I need it to convert to my local time through the result obtained by the code above
Score:1
ru flag

The following will show that date in local time, using date --date=STRING

date --date="$(curl -I 'https://google.com/' 2>/dev/null | grep -i '^date:' | sed -e 's/^date: //')"
Jaromanda X avatar
ru flag
why are you extracting the year and thinking it's the hour? you save the year to `/root/hora.txt` - you read `/root/hour.txt` (what created that?) into `hour2`, you set the time to `$time2UTC` (not defined) ... you `echo $hour` (not defined) - that whole script is hot garbage
Jaromanda X avatar
ru flag
my code extracts full date and time ... yours, with the `cut` extracts year (at least on my system)
Jaromanda X avatar
ru flag
tell me, exactly what is the result of MY code on your system? note, your code does `date +%T%Z -s "$hourUTC"` ... and `$hourUTC` is what? and why are you setting the system clock to whatever that is?
Jaromanda X avatar
ru flag
again, this is all beyond the original question asked - you asked, I answered ... if you're then going to do bizarre things with the result that mainly make no sense, that doesn't mean this answer is wrong ... it answers exactly what you asked
Luana avatar
mr flag
I understand, again thanks for your help friend.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.