How can I get UTC time in a bash script variable?

Hi I have a script that needs utc time and I am using

eDateTime=`date +"%Y%m%d_%H%M%S"`


It isnt returning UTC time from what I can see.


Any tips?


Many thanks

Posted on Jul 5, 2022 11:50 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 6, 2022 7:24 AM

eDateTime=$(date -u +"%Y%m%d_%T")

20220706_14:13:53


The -u switch returns UTC time, and in the preceding case, this was done at 10:13 EDT today. The back ticks (`) are antiquated shell semantics and have been superceded with the $() expression.

4 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How can I get UTC time in a bash script variable?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.