DEV Community

Abdallah Kordy
Abdallah Kordy

Posted on • Updated 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

Top comments (0)