Getting time zone date command line linux

10,622

Solution 1

You can set the timezone just for the one call to the date command (without changing the timezone that your system is set to) like so:

TZ=Asia/Calcutta date

Note the space before the date command.

Solution 2

Maybe this is the wrong way, but try setting the time zone, then calling date, then unsetting the time zone.

export TZ=Asia/Calcutta
date
unset TZ

There's a small list here of the time zones: Link To Wikipedia.

Share:
10,622
Phi
Author by

Phi

Favorite language: C#, SQL for SQL Server. Favorite technology: ASP.NET :)

Updated on June 04, 2022

Comments

  • Phi
    Phi almost 2 years

    I'm trying to use $date -u to get UTC time zone. It works fine but how can i set GTM to get a different time zone. For example, how can i complete that command to check GMT+5 or GMT+6 time zone in command line in Linux?

    Any idea how can i do it?