Questions tagged [date]

the "date" tag is used to classify questions about date/calendar/time manipulation, visualisation, conversion... on Unix-like systems.

The tag should be used for questions that are about handling calendar dates on Unix-like systems like for instance:

  • How to convert dates from different formats or calendars
  • How to do calculations on dates
  • The date-related utilities, in particular the date command and its variants like the GNU version. Or the dateutils series of commands.
  • The display, nationalisation of dates

Related tags:

  • : more appropriate for setting or synchronising the time on a system.
  • : more appropriate for discussing calendaring software.
  • : can be used in combination with to further qualify timezone-specific questions.
  • : for the network time protocol.
  • : for questions related to tag events with dates.
1172 questions
231
votes
5 answers

date command --iso-8601 option

This answer and comments mention --rfc-3339 and a "hidden" --iso-8601 option that I have used for a long time and now seems to be undocumented. When did that option documentation get removed from the --help text? Will the option go away anytime…
Angelo
  • 2,319
140
votes
18 answers

Quickly calculate date differences

I often want to make some quick date calculations, such as: What is the difference between these two dates? What is the date n weeks after this other date? I usually open a calendar and count the days, but I think there should be a program/script…
daniel kullmann
  • 9,527
  • 11
  • 39
  • 46
38
votes
7 answers

What is a standard command for printing a date in RFC-3339 format?

The date command doesn't offer such thing, which is kind of sad since RFC-3339 is the modern, widespread, sane format used everywhere (except in email which is neither modern nor sane). My timezone offset is currently -08:00 so the simplest form of…
32
votes
3 answers

How do you specify a format for the input to date?

Given a date and time in a format that is not recognized by date, how can I get date to recognize the date and time? For example: $ date -d "09SEP2012:23:58:46" date: invalid date `09SEP2012:23:58:46' $ date -d "09SEP2012:23:58:46" --magic-option…
Cory Klein
  • 18,911
27
votes
9 answers

Year 2038 problem

What is the likelihood of the Year 2038 issue being very problematic?
8128
  • 405
18
votes
4 answers

How do I find seconds since midnight?

Using the date program, how can I calculate the number of seconds since midnight?
Ducky
  • 193
12
votes
3 answers

How to use the date command to find out what date "monday week 40" will be?

How can I use the date command to convert something like "monday week 40" into a ISO date? I am playing with something like this: date --date='monday week 40' +'%Y-%m-%d' And the date I'm searching for would be 2011-10-03. But my problem is that…
Johan
  • 4,583
9
votes
1 answer

Why are these 2 date commands giving different results?

$ date -d "Apr 1 2016 - 1 month" +%B gives me "March", which is great - the month that comes before April is March. If I do this however: $ date -d "$(date -d "Apr 1 2016") - 1 month" +%B it gives me "February". This is causing a bug in some more…
Tal
  • 2,112
9
votes
1 answer

How to set date with Epoch format

I want to set date from a seconds since epoch value, for instance I want to set date with input value 1452053571. I read through date -help but not found anything. Is there any parameters to do it?
7
votes
4 answers

Date computations without GNU tools

I have to perform some date calculations and conversion in a shell script. For example computing the difference in day between a date formatted as Nov 28 20:27:19 2012 GMT and today. There are several possibilities (GNU date, gawk, perl, etc.) but I…
Matteo
  • 9,796
  • 4
  • 51
  • 66
6
votes
1 answer

Is there a reserved word for datetime for the start of the day?

man date won't show me any reserved words but they have 'now' or 'today' etc. I wonder if there is any clear way to print start(00:00:00) of the day. Will date -u -d "$(date +'%F')" suffice in any situation? Looks a little dumb.
Lunartist
  • 385
6
votes
2 answers

How can I convert a local date-time into UTC date-time?

I am trying to get a bash script working and in order to do so I need to transform a local time in +%Y%m%d%H%M%S format (example: "20150903170731") into UTC time in the same format. I know date -u can give me the current UTC time: $ date…
Franco
  • 167
4
votes
4 answers

How to get a previous date using a reference to a file with the date command?

I'm trying to get Previous date of reference file. What I've tried : [rahul@testsrv]$ date +%F -r /tmp/ftpbkp.log 2013-08-27 [rahul@testsrv]$ date +%F -r /tmp/ftpbkp.log -d "1 day ago" date: the options to specify dates for printing are mutually…
Rahul Patil
  • 24,711
4
votes
1 answer

How to show full day name with command of e.g. Jul 16 1991

I found out that date --date 'Jul 16 1991' has an complete output, but I only want the terminal to show the name of the day e.g. Monday. How do I do that?
4
votes
3 answers

How can I get 'date' command show AM/PM time by default

I am looking to have my date command show time: mohi@DESKTOP-PM4LGGS:~/Dropbox/mpl$ date Mon, Jul 30, 2018 3:31:41 PM like I am seeing in my Git Bash on my office Windows. How can I get my date command show AM/PM time by default on my home Ubuntu…
1
2 3 4 5