Get Current Date and Time on Linux

Get Current Date and Time on Linux

Knowing how to retrieve the current date and time on a Linux system is essential for system administration, scripting, and logging. The date command on Linux allows users to display and format the current date and time. This tutorial explains how to get current date and time on Linux.

1. Current date and time (Local)

To get the current system date and time in your local timezone, simply use:

date

Example output:

Sun Feb  2 01:37:54 EST 2025

2. Current date and time (UTC)

If you need to retrieve the current date and time in Coordinated Universal Time (UTC), use the -u option:

date -u

Example output:

Sun Feb  2 06:37:54 UTC 2025

3. Current date and time in ISO 8601 format (Local)

The ISO 8601 format is commonly used in logs and automation. To display the current date and time in local time with this format, use:

date +"%Y-%m-%dT%H:%M:%S%:z"

Example output:

2025-02-02T01:37:54-05:00

4. Current date and time in ISO 8601 format (UTC)

To retrieve the current date and time in UTC using ISO 8601 format, run:

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

Example output:

2025-02-02T06:37:54+00:00

Leave a Comment

Cancel reply

Your email address will not be published.