How to get IST in Unix if my current timezone is UTC. Also I need to get the time format to be dd/mm/yyyy hr:min:sec?

I have just started learning about the date command in Unix.
I have typed the below code to get the IST. But I don’t know how to convert it to a specific format.

TZ = IST-5:30 date

This gives the result as Thu Feb 10:31:51 IST 2022.

But I want the output to be 03/02/2022 10:31:51 IST.

Is there any way to get the output?

>Solution :

With date (GNU coreutils) 8.32 you can use the +FORMAT argument:

TZ=IST-5:30 date +'%d/%m/%y %T %Z'
03/02/22 10:46:50 IST

%x would be a better choice instead of %d/%m/%y if your locale allows for it.

Leave a Reply