ls -lt shows time in PDT, I want to change it to Asia/Singapore in the current session. I tried set TZ=Asia/Singapore But it's showing the same time on ls -lt.

How to do it?

  • set TZ=Asia/Singapore? Are you using (t)csh? – muru Jun 20 '18 at 3:56
  • Could you please confirm what shell you use as login shell? What does echo "$SHELL" say? – Kusalananda Jun 20 '18 at 5:38
  • echo "$SHELL" shows this --> /bin/csh – Codeformer Jun 20 '18 at 7:05

To set the TZ environment variable in csh, use

sentenv TZ Asia/Singapore

For the current shell session, use the TZ environment variable by running the command:

export TZ=Asia/Singapore

For this change to persist beyond this shell session, you'll need to change the file that stores the time zone. In Red Hat-based systems, that's the /etc/localtime file. You'll want to remove it and replace it with the correct timezone. Other timezones are present in the /usb/share/zoneinfo directory.


sudo rm /etc/localtime


sudo cp /usr/share/zoneinfo/Asia/Singapore /etc/localtime

Running date should give you the right output now.

  • it says export: Command not found – Codeformer Jun 20 '18 at 4:57
  • 1
    It sounds like you might not be using bash then. So try set TZ=Asia/Singapore or setenv TZ Asia/Singapore. – baelx Jun 20 '18 at 5:25

Simple way to change timezone is to use shell variable TZ. You can do it with single line command as below :

bash -c "export TZ=Asia/Singapore"

This timezone setting will be available for current shell only from where you are exporting this TZ variable.

  • I tried , it says export: Command not found. – Codeformer Jun 20 '18 at 4:57
  • @Codeformer I have updated export bash command. Try this code bash -c "export TZ=Asia/Singapore" – Ehtesham Jun 20 '18 at 5:34
  • 3
    You can't set an environment variable in a child process (your bash -c shell) and expect it to be set in the current interactive shell. – Kusalananda Jun 20 '18 at 5:37
  • Yes, you can. Checkout this link [stackoverflow.com/a/10144965/2339542] – Ehtesham Jun 20 '18 at 5:42
  • 1
    @Ehtesham That answer shows that it can't be done. Sorry. – Kusalananda Jun 20 '18 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.