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?
CodePudding user response:
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.