DEV Community

Abdallah Kordy
Abdallah Kordy

Posted on • Edited on

Linux Date Commands

Explaining different date formats according to your needs
1.Date

  • date -u :Displays the time in Coordinated Universal Time (UTC).
04 يون, 2024 UTC 07:32:39 م
Enter fullscreen mode Exit fullscreen mode
  • date -d "next Friday"
07 يون, 2024 EEST 12:00:00 ص

Enter fullscreen mode Exit fullscreen mode
  • date -R Outputs the date and time in RFC 2822 format.

output

Tue, 04 Jun 2024 22:37:39 +0300

Enter fullscreen mode Exit fullscreen mode
  • date -I :Outputs the date in ISO 8601 format

output

2024-06-04
Enter fullscreen mode Exit fullscreen mode
  • date "+%Y-%m-%d %H:%M:%S" customizable formate
2024-06-04 22:49:23
Enter fullscreen mode Exit fullscreen mode

%Y: Year (4 digits)
%m: Month (2 digits)
%d: Day (2 digits)
%H: Hour (00-23)
%M: Minute (00-59)
%S: Second (00-59)
%A: Full weekday name (e.g., Monday)
%a: Abbreviated weekday name (e.g., Mon)
%B: Full month name (e.g., January)
%b: Abbreviated month name (e.g., Jan)

  • date -s or --set: date -s "2023-12-31 23:59:59"
    Sets the system date and time.

  • date --rfc-3339=seconds

2024-06-04 23:10:08+03:00
Enter fullscreen mode Exit fullscreen mode
  • date -d "2023-12-31 23:59:59" Display the date and time for a specific date:
31 ديس, 2023 EET 11:59:59 م
Enter fullscreen mode Exit fullscreen mode

Billboard image

Imagine monitoring that's actually built for developers

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay