Why does `date` show UTC time, even with a different timezone set?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I'm running Raspbian on a Pi 2. While I'm not sure this behavior was different previously, running date outputs the same time as date -u, despite my timezone being UTC-7. Below is the output of both of the above commands, and my $TZ variable:



pi@raspberrypi ~ $ date; date -u; echo $TZ
Sat Oct 3 05:33:43 America 2015
Sat Oct 3 05:33:43 UTC 2015
America/Los Angeles


How can I change this output to show the correct time/date? (eg. Oct 2 10:33:43 America 2015 as the output for date)










share|improve this question



















  • 1





    I notice there is a space instead of an underscore in "Los Angeles"; not sure if that makes a difference, but tzselect output has an underscore in it....

    – Wildcard
    Oct 3 '15 at 5:49

















4















I'm running Raspbian on a Pi 2. While I'm not sure this behavior was different previously, running date outputs the same time as date -u, despite my timezone being UTC-7. Below is the output of both of the above commands, and my $TZ variable:



pi@raspberrypi ~ $ date; date -u; echo $TZ
Sat Oct 3 05:33:43 America 2015
Sat Oct 3 05:33:43 UTC 2015
America/Los Angeles


How can I change this output to show the correct time/date? (eg. Oct 2 10:33:43 America 2015 as the output for date)










share|improve this question



















  • 1





    I notice there is a space instead of an underscore in "Los Angeles"; not sure if that makes a difference, but tzselect output has an underscore in it....

    – Wildcard
    Oct 3 '15 at 5:49













4












4








4








I'm running Raspbian on a Pi 2. While I'm not sure this behavior was different previously, running date outputs the same time as date -u, despite my timezone being UTC-7. Below is the output of both of the above commands, and my $TZ variable:



pi@raspberrypi ~ $ date; date -u; echo $TZ
Sat Oct 3 05:33:43 America 2015
Sat Oct 3 05:33:43 UTC 2015
America/Los Angeles


How can I change this output to show the correct time/date? (eg. Oct 2 10:33:43 America 2015 as the output for date)










share|improve this question
















I'm running Raspbian on a Pi 2. While I'm not sure this behavior was different previously, running date outputs the same time as date -u, despite my timezone being UTC-7. Below is the output of both of the above commands, and my $TZ variable:



pi@raspberrypi ~ $ date; date -u; echo $TZ
Sat Oct 3 05:33:43 America 2015
Sat Oct 3 05:33:43 UTC 2015
America/Los Angeles


How can I change this output to show the correct time/date? (eg. Oct 2 10:33:43 America 2015 as the output for date)







date timezone






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 13:02









Rui F Ribeiro

41.9k1483142




41.9k1483142










asked Oct 3 '15 at 5:39









NightfirecatNightfirecat

12315




12315







  • 1





    I notice there is a space instead of an underscore in "Los Angeles"; not sure if that makes a difference, but tzselect output has an underscore in it....

    – Wildcard
    Oct 3 '15 at 5:49












  • 1





    I notice there is a space instead of an underscore in "Los Angeles"; not sure if that makes a difference, but tzselect output has an underscore in it....

    – Wildcard
    Oct 3 '15 at 5:49







1




1





I notice there is a space instead of an underscore in "Los Angeles"; not sure if that makes a difference, but tzselect output has an underscore in it....

– Wildcard
Oct 3 '15 at 5:49





I notice there is a space instead of an underscore in "Los Angeles"; not sure if that makes a difference, but tzselect output has an underscore in it....

– Wildcard
Oct 3 '15 at 5:49










1 Answer
1






active

oldest

votes


















3














You have have the timezone set incorrect. To see if it works at all use some others (the extremes):



$ TZ=Pacific/Midway date
Mon Sep 28 20:42:02 SST 2015
$ TZ=Pacific/Kiritimati date
Tue Sep 29 21:42:48 LINT 2015


and if you double check your entry against the list you can see you're missing an underscore in the value of $TZ.



So try



$ TZ=America/Los_Angeles date


and see if your problem persists.



I haven't found any policy for the naming of the timezones, but spaces are never in them and replaced by underscore, but sometimes with a dash. It is probably best to look it up and copy/paste the value, something you, or your source didn't.






share|improve this answer

























  • Looks like this is the cause of the issue, but simply exporting the right string doesn't seem to carry over after a system restart. /etc/timezone appears to have the correct string, but doesn't seem like it applies itself. Running dpkg-reconfigure tzdata seems to replace the underscore with a space as well.

    – Nightfirecat
    Oct 3 '15 at 10:10






  • 1





    @Nightfirecat No exporting is not enough, but it is the way to test if you got the correct string without having to reboot. My system has no TZ set in the environment at all and still gets the correct timezone (from /etc/timezone, so it looks like one of the scripts executed on shell startup for you sets this incorrectly. Try unset TZ to see if that solves it.

    – Anthon
    Oct 3 '15 at 10:14












  • Well, trick question -- looks like I exported the wrong TZ string in my .profile a while back and never realized it. My bad! :)

    – Nightfirecat
    Oct 3 '15 at 10:14











  • @Nightfirecat I just edit my previous comments while you were commenting with exact that info.

    – Anthon
    Oct 3 '15 at 10:16











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f233637%2fwhy-does-date-show-utc-time-even-with-a-different-timezone-set%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














You have have the timezone set incorrect. To see if it works at all use some others (the extremes):



$ TZ=Pacific/Midway date
Mon Sep 28 20:42:02 SST 2015
$ TZ=Pacific/Kiritimati date
Tue Sep 29 21:42:48 LINT 2015


and if you double check your entry against the list you can see you're missing an underscore in the value of $TZ.



So try



$ TZ=America/Los_Angeles date


and see if your problem persists.



I haven't found any policy for the naming of the timezones, but spaces are never in them and replaced by underscore, but sometimes with a dash. It is probably best to look it up and copy/paste the value, something you, or your source didn't.






share|improve this answer

























  • Looks like this is the cause of the issue, but simply exporting the right string doesn't seem to carry over after a system restart. /etc/timezone appears to have the correct string, but doesn't seem like it applies itself. Running dpkg-reconfigure tzdata seems to replace the underscore with a space as well.

    – Nightfirecat
    Oct 3 '15 at 10:10






  • 1





    @Nightfirecat No exporting is not enough, but it is the way to test if you got the correct string without having to reboot. My system has no TZ set in the environment at all and still gets the correct timezone (from /etc/timezone, so it looks like one of the scripts executed on shell startup for you sets this incorrectly. Try unset TZ to see if that solves it.

    – Anthon
    Oct 3 '15 at 10:14












  • Well, trick question -- looks like I exported the wrong TZ string in my .profile a while back and never realized it. My bad! :)

    – Nightfirecat
    Oct 3 '15 at 10:14











  • @Nightfirecat I just edit my previous comments while you were commenting with exact that info.

    – Anthon
    Oct 3 '15 at 10:16















3














You have have the timezone set incorrect. To see if it works at all use some others (the extremes):



$ TZ=Pacific/Midway date
Mon Sep 28 20:42:02 SST 2015
$ TZ=Pacific/Kiritimati date
Tue Sep 29 21:42:48 LINT 2015


and if you double check your entry against the list you can see you're missing an underscore in the value of $TZ.



So try



$ TZ=America/Los_Angeles date


and see if your problem persists.



I haven't found any policy for the naming of the timezones, but spaces are never in them and replaced by underscore, but sometimes with a dash. It is probably best to look it up and copy/paste the value, something you, or your source didn't.






share|improve this answer

























  • Looks like this is the cause of the issue, but simply exporting the right string doesn't seem to carry over after a system restart. /etc/timezone appears to have the correct string, but doesn't seem like it applies itself. Running dpkg-reconfigure tzdata seems to replace the underscore with a space as well.

    – Nightfirecat
    Oct 3 '15 at 10:10






  • 1





    @Nightfirecat No exporting is not enough, but it is the way to test if you got the correct string without having to reboot. My system has no TZ set in the environment at all and still gets the correct timezone (from /etc/timezone, so it looks like one of the scripts executed on shell startup for you sets this incorrectly. Try unset TZ to see if that solves it.

    – Anthon
    Oct 3 '15 at 10:14












  • Well, trick question -- looks like I exported the wrong TZ string in my .profile a while back and never realized it. My bad! :)

    – Nightfirecat
    Oct 3 '15 at 10:14











  • @Nightfirecat I just edit my previous comments while you were commenting with exact that info.

    – Anthon
    Oct 3 '15 at 10:16













3












3








3







You have have the timezone set incorrect. To see if it works at all use some others (the extremes):



$ TZ=Pacific/Midway date
Mon Sep 28 20:42:02 SST 2015
$ TZ=Pacific/Kiritimati date
Tue Sep 29 21:42:48 LINT 2015


and if you double check your entry against the list you can see you're missing an underscore in the value of $TZ.



So try



$ TZ=America/Los_Angeles date


and see if your problem persists.



I haven't found any policy for the naming of the timezones, but spaces are never in them and replaced by underscore, but sometimes with a dash. It is probably best to look it up and copy/paste the value, something you, or your source didn't.






share|improve this answer















You have have the timezone set incorrect. To see if it works at all use some others (the extremes):



$ TZ=Pacific/Midway date
Mon Sep 28 20:42:02 SST 2015
$ TZ=Pacific/Kiritimati date
Tue Sep 29 21:42:48 LINT 2015


and if you double check your entry against the list you can see you're missing an underscore in the value of $TZ.



So try



$ TZ=America/Los_Angeles date


and see if your problem persists.



I haven't found any policy for the naming of the timezones, but spaces are never in them and replaced by underscore, but sometimes with a dash. It is probably best to look it up and copy/paste the value, something you, or your source didn't.







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 3 '15 at 6:25

























answered Oct 3 '15 at 6:18









AnthonAnthon

61.5k17107170




61.5k17107170












  • Looks like this is the cause of the issue, but simply exporting the right string doesn't seem to carry over after a system restart. /etc/timezone appears to have the correct string, but doesn't seem like it applies itself. Running dpkg-reconfigure tzdata seems to replace the underscore with a space as well.

    – Nightfirecat
    Oct 3 '15 at 10:10






  • 1





    @Nightfirecat No exporting is not enough, but it is the way to test if you got the correct string without having to reboot. My system has no TZ set in the environment at all and still gets the correct timezone (from /etc/timezone, so it looks like one of the scripts executed on shell startup for you sets this incorrectly. Try unset TZ to see if that solves it.

    – Anthon
    Oct 3 '15 at 10:14












  • Well, trick question -- looks like I exported the wrong TZ string in my .profile a while back and never realized it. My bad! :)

    – Nightfirecat
    Oct 3 '15 at 10:14











  • @Nightfirecat I just edit my previous comments while you were commenting with exact that info.

    – Anthon
    Oct 3 '15 at 10:16

















  • Looks like this is the cause of the issue, but simply exporting the right string doesn't seem to carry over after a system restart. /etc/timezone appears to have the correct string, but doesn't seem like it applies itself. Running dpkg-reconfigure tzdata seems to replace the underscore with a space as well.

    – Nightfirecat
    Oct 3 '15 at 10:10






  • 1





    @Nightfirecat No exporting is not enough, but it is the way to test if you got the correct string without having to reboot. My system has no TZ set in the environment at all and still gets the correct timezone (from /etc/timezone, so it looks like one of the scripts executed on shell startup for you sets this incorrectly. Try unset TZ to see if that solves it.

    – Anthon
    Oct 3 '15 at 10:14












  • Well, trick question -- looks like I exported the wrong TZ string in my .profile a while back and never realized it. My bad! :)

    – Nightfirecat
    Oct 3 '15 at 10:14











  • @Nightfirecat I just edit my previous comments while you were commenting with exact that info.

    – Anthon
    Oct 3 '15 at 10:16
















Looks like this is the cause of the issue, but simply exporting the right string doesn't seem to carry over after a system restart. /etc/timezone appears to have the correct string, but doesn't seem like it applies itself. Running dpkg-reconfigure tzdata seems to replace the underscore with a space as well.

– Nightfirecat
Oct 3 '15 at 10:10





Looks like this is the cause of the issue, but simply exporting the right string doesn't seem to carry over after a system restart. /etc/timezone appears to have the correct string, but doesn't seem like it applies itself. Running dpkg-reconfigure tzdata seems to replace the underscore with a space as well.

– Nightfirecat
Oct 3 '15 at 10:10




1




1





@Nightfirecat No exporting is not enough, but it is the way to test if you got the correct string without having to reboot. My system has no TZ set in the environment at all and still gets the correct timezone (from /etc/timezone, so it looks like one of the scripts executed on shell startup for you sets this incorrectly. Try unset TZ to see if that solves it.

– Anthon
Oct 3 '15 at 10:14






@Nightfirecat No exporting is not enough, but it is the way to test if you got the correct string without having to reboot. My system has no TZ set in the environment at all and still gets the correct timezone (from /etc/timezone, so it looks like one of the scripts executed on shell startup for you sets this incorrectly. Try unset TZ to see if that solves it.

– Anthon
Oct 3 '15 at 10:14














Well, trick question -- looks like I exported the wrong TZ string in my .profile a while back and never realized it. My bad! :)

– Nightfirecat
Oct 3 '15 at 10:14





Well, trick question -- looks like I exported the wrong TZ string in my .profile a while back and never realized it. My bad! :)

– Nightfirecat
Oct 3 '15 at 10:14













@Nightfirecat I just edit my previous comments while you were commenting with exact that info.

– Anthon
Oct 3 '15 at 10:16





@Nightfirecat I just edit my previous comments while you were commenting with exact that info.

– Anthon
Oct 3 '15 at 10:16

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f233637%2fwhy-does-date-show-utc-time-even-with-a-different-timezone-set%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?