Friday, January 17, 2025
HomeTechWhat is the easiest way to get current GMT time in Unix?

What is the easiest way to get current GMT time in Unix?

The easiest way to get the current GMT (Greenwich Mean Time) time in Unix is to use the date command in the terminal with the -u option, which tells the system to display the time in GMT (UTC) instead of the local time zone.

Command:

date -u

Explanation:

  • The -u flag tells the date command to output the current time in UTC (Coordinated Universal Time), which is essentially the same as GMT.
  • This command will print the current date and time in GMT/UTC in a default format.
See also  Difference Between Decimal and Binary Number System

Example Output:

Thu Jan 17 12:34:56 UTC 2025

This gives you the current time in UTC, which is equivalent to GMT.

Additional Customization:

You can also format the output of the date command to match specific requirements. For example, to get the GMT time in a specific format like YYYY-MM-DD HH:MM:SS, you can use:

date -u +"%Y-%m-%d %H:%M:%S"

Example Output:

2025-01-17 12:34:56

This will provide the current GMT time in a more readable format.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x