Invalid date error by date commandHow can I change the default date output format for the date command?Date format in UNIXHaving problem displaying date?Change “date” Command To 12 Hour Time Instead Of 24how to fix odd date (commandline command) formatDate off by years - Cannot set dateFrom where `date` retrieve date?Passing a date in an exiftool commandHow to use “date” command parametersWhat is the date command line corresponding to var=“$(date +”%x %r %Z“)”

What if a revenant (monster) gains fire resistance?

Invalid date error by date command

Why is it that I can sometimes guess the next note?

Does Doodling or Improvising on the Piano Have Any Benefits?

Can a stoichiometric mixture of oxygen and methane exist as a liquid at standard pressure and some (low) temperature?

Plot of a tornado-shaped surface

How could a planet have erratic days?

15% tax on $7.5k earnings. Is that right?

How can I avoid dust and bubbles when installing window film?

Is this toilet slogan correct usage of the English language?

User Story breakdown - Technical Task + User Feature

What are the balance implications behind making invisible things auto-hide?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

How do you make your own symbol when Detexify fails?

Mixing PEX brands

How do apertures which seem too large to physically fit work?

Biological Blimps: Propulsion

Non-trope happy ending?

Bridge building with irregular planks

Make a Bowl of Alphabet Soup

Recommended PCB layout understanding - ADM2572 datasheet

Yosemite Fire Rings - What to Expect?

Example of factorization in a polynomial ring which is not an UFD

Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?



Invalid date error by date command


How can I change the default date output format for the date command?Date format in UNIXHaving problem displaying date?Change “date” Command To 12 Hour Time Instead Of 24how to fix odd date (commandline command) formatDate off by years - Cannot set dateFrom where `date` retrieve date?Passing a date in an exiftool commandHow to use “date” command parametersWhat is the date command line corresponding to var=“$(date +”%x %r %Z“)”













5















I want to get the date information with this command:



date --date=2019-03-22


or



date --date=2019/03/22


but it shows this error:



date: invalid date ‘2019-03-22’


or



 date: invalid date ‘2019/03/22’


as you can see it is not related to dash. the same thing happens with slash.



When I use another date like



date --date=2019-03-21


It shows the information correctly.



Screenshot:



date invalid date error screenshot



It shouldn't be related to the bad dash character. because I just deleted the last 2 and replaced it with 1 and the output is OK.



What is going wrong?



Result of some commands for more information:



$ date --version
date (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.


$ type -a date
date is /bin/date


$ uname -m
x86_64


$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic


$ which date
/bin/date


$ apt-cache policy coreutils
coreutils:
Installed: 8.28-1ubuntu1
Candidate: 8.28-1ubuntu1
Version table:
*** 8.28-1ubuntu1 500
500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
100 /var/lib/dpkg/status


$ date
Fri Mar 22 06:54:59 PDT 2019


date --date=2019-03-22 2>&1 | od -c
0000000 d a t e : i n v a l i d d a
0000020 t e 342 200 230 2 0 1 9 - 0 3 - 2 2
0000040 342 200 231 n
0000044


Something weird going on with different timezone in this date: 2019-03-22. I randomly changed timezone to different areas. Some of them have errors, some of them not! When I select these I have problem with that specific date:



  • Los Angeles (USA)

  • Shanghai (China)

  • Madrid (Spain)

  • Tehran (Iran)









share|improve this question
























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    2 hours ago















5















I want to get the date information with this command:



date --date=2019-03-22


or



date --date=2019/03/22


but it shows this error:



date: invalid date ‘2019-03-22’


or



 date: invalid date ‘2019/03/22’


as you can see it is not related to dash. the same thing happens with slash.



When I use another date like



date --date=2019-03-21


It shows the information correctly.



Screenshot:



date invalid date error screenshot



It shouldn't be related to the bad dash character. because I just deleted the last 2 and replaced it with 1 and the output is OK.



What is going wrong?



Result of some commands for more information:



$ date --version
date (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.


$ type -a date
date is /bin/date


$ uname -m
x86_64


$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic


$ which date
/bin/date


$ apt-cache policy coreutils
coreutils:
Installed: 8.28-1ubuntu1
Candidate: 8.28-1ubuntu1
Version table:
*** 8.28-1ubuntu1 500
500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
100 /var/lib/dpkg/status


$ date
Fri Mar 22 06:54:59 PDT 2019


date --date=2019-03-22 2>&1 | od -c
0000000 d a t e : i n v a l i d d a
0000020 t e 342 200 230 2 0 1 9 - 0 3 - 2 2
0000040 342 200 231 n
0000044


Something weird going on with different timezone in this date: 2019-03-22. I randomly changed timezone to different areas. Some of them have errors, some of them not! When I select these I have problem with that specific date:



  • Los Angeles (USA)

  • Shanghai (China)

  • Madrid (Spain)

  • Tehran (Iran)









share|improve this question
























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    2 hours ago













5












5








5








I want to get the date information with this command:



date --date=2019-03-22


or



date --date=2019/03/22


but it shows this error:



date: invalid date ‘2019-03-22’


or



 date: invalid date ‘2019/03/22’


as you can see it is not related to dash. the same thing happens with slash.



When I use another date like



date --date=2019-03-21


It shows the information correctly.



Screenshot:



date invalid date error screenshot



It shouldn't be related to the bad dash character. because I just deleted the last 2 and replaced it with 1 and the output is OK.



What is going wrong?



Result of some commands for more information:



$ date --version
date (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.


$ type -a date
date is /bin/date


$ uname -m
x86_64


$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic


$ which date
/bin/date


$ apt-cache policy coreutils
coreutils:
Installed: 8.28-1ubuntu1
Candidate: 8.28-1ubuntu1
Version table:
*** 8.28-1ubuntu1 500
500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
100 /var/lib/dpkg/status


$ date
Fri Mar 22 06:54:59 PDT 2019


date --date=2019-03-22 2>&1 | od -c
0000000 d a t e : i n v a l i d d a
0000020 t e 342 200 230 2 0 1 9 - 0 3 - 2 2
0000040 342 200 231 n
0000044


Something weird going on with different timezone in this date: 2019-03-22. I randomly changed timezone to different areas. Some of them have errors, some of them not! When I select these I have problem with that specific date:



  • Los Angeles (USA)

  • Shanghai (China)

  • Madrid (Spain)

  • Tehran (Iran)









share|improve this question
















I want to get the date information with this command:



date --date=2019-03-22


or



date --date=2019/03/22


but it shows this error:



date: invalid date ‘2019-03-22’


or



 date: invalid date ‘2019/03/22’


as you can see it is not related to dash. the same thing happens with slash.



When I use another date like



date --date=2019-03-21


It shows the information correctly.



Screenshot:



date invalid date error screenshot



It shouldn't be related to the bad dash character. because I just deleted the last 2 and replaced it with 1 and the output is OK.



What is going wrong?



Result of some commands for more information:



$ date --version
date (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.


$ type -a date
date is /bin/date


$ uname -m
x86_64


$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic


$ which date
/bin/date


$ apt-cache policy coreutils
coreutils:
Installed: 8.28-1ubuntu1
Candidate: 8.28-1ubuntu1
Version table:
*** 8.28-1ubuntu1 500
500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
100 /var/lib/dpkg/status


$ date
Fri Mar 22 06:54:59 PDT 2019


date --date=2019-03-22 2>&1 | od -c
0000000 d a t e : i n v a l i d d a
0000020 t e 342 200 230 2 0 1 9 - 0 3 - 2 2
0000040 342 200 231 n
0000044


Something weird going on with different timezone in this date: 2019-03-22. I randomly changed timezone to different areas. Some of them have errors, some of them not! When I select these I have problem with that specific date:



  • Los Angeles (USA)

  • Shanghai (China)

  • Madrid (Spain)

  • Tehran (Iran)






command-line date






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 4 hours ago







ICE

















asked 6 hours ago









ICEICE

8423724




8423724












  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    2 hours ago

















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Thomas Ward
    2 hours ago
















Comments are not for extended discussion; this conversation has been moved to chat.

– Thomas Ward
2 hours ago





Comments are not for extended discussion; this conversation has been moved to chat.

– Thomas Ward
2 hours ago










2 Answers
2






active

oldest

votes


















1














I'm almost sure this is due to the change over to daylight saving time in the given timezone: effectively this means that an hour "disappears" (and hence becomes "invalid"). In my own timezone, DST started at 2AM on Sunday 10th March, so that hour is invalid:



$ cat /etc/timezone
America/Toronto
$ date --date="2019-03-10 02:00:00"
date: invalid date ‘2019-03-10 02:00:00’


whereas the hours before and after are valid:



steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 01:00:00"
Sun Mar 10 01:00:00 EST 2019
steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 03:00:00"
Sun Mar 10 03:00:00 EDT 2019


In timezones where the change over happens at midnight, the bare date appears invalid because GNU date assumes a time of midnight:



$ TZ=Asia/Tehran date --date='2019-03-22'
date: invalid date ‘2019-03-22’


but one hour later is valid:



$ TZ=Asia/Tehran date --date='2019-03-22 01:00:00'
Fri Mar 22 01:00:00 +0430 2019





share|improve this answer























  • Thanks, adding time to date fixed the problem.

    – ICE
    3 mins ago



















2














$ date_ascii="2019-03-22"
$ printf "%s" "$date_ascii" | od -c
0000000 2 0 1 9 - 0 3 - 2 2
0000012
$ TZ=Asia/Shanghai date -d "$date_ascii"
Fri Mar 22 00:00:00 America 2019


and



$ date_unicode="2019‑03‑22"
$ printf "%s" "$date_unicode" | od -c
0000000 2 0 1 9 342 200 221 0 3 342 200 221 2 2
0000016
$ TZ=Asia/Shanghai date -d "$date_unicode"
date: invalid date ‘2019‑03‑22’





share|improve this answer























  • Seems There is something wrong with timezone in my system :(

    – ICE
    4 hours ago










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1127834%2finvalid-date-error-by-date-command%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I'm almost sure this is due to the change over to daylight saving time in the given timezone: effectively this means that an hour "disappears" (and hence becomes "invalid"). In my own timezone, DST started at 2AM on Sunday 10th March, so that hour is invalid:



$ cat /etc/timezone
America/Toronto
$ date --date="2019-03-10 02:00:00"
date: invalid date ‘2019-03-10 02:00:00’


whereas the hours before and after are valid:



steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 01:00:00"
Sun Mar 10 01:00:00 EST 2019
steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 03:00:00"
Sun Mar 10 03:00:00 EDT 2019


In timezones where the change over happens at midnight, the bare date appears invalid because GNU date assumes a time of midnight:



$ TZ=Asia/Tehran date --date='2019-03-22'
date: invalid date ‘2019-03-22’


but one hour later is valid:



$ TZ=Asia/Tehran date --date='2019-03-22 01:00:00'
Fri Mar 22 01:00:00 +0430 2019





share|improve this answer























  • Thanks, adding time to date fixed the problem.

    – ICE
    3 mins ago
















1














I'm almost sure this is due to the change over to daylight saving time in the given timezone: effectively this means that an hour "disappears" (and hence becomes "invalid"). In my own timezone, DST started at 2AM on Sunday 10th March, so that hour is invalid:



$ cat /etc/timezone
America/Toronto
$ date --date="2019-03-10 02:00:00"
date: invalid date ‘2019-03-10 02:00:00’


whereas the hours before and after are valid:



steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 01:00:00"
Sun Mar 10 01:00:00 EST 2019
steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 03:00:00"
Sun Mar 10 03:00:00 EDT 2019


In timezones where the change over happens at midnight, the bare date appears invalid because GNU date assumes a time of midnight:



$ TZ=Asia/Tehran date --date='2019-03-22'
date: invalid date ‘2019-03-22’


but one hour later is valid:



$ TZ=Asia/Tehran date --date='2019-03-22 01:00:00'
Fri Mar 22 01:00:00 +0430 2019





share|improve this answer























  • Thanks, adding time to date fixed the problem.

    – ICE
    3 mins ago














1












1








1







I'm almost sure this is due to the change over to daylight saving time in the given timezone: effectively this means that an hour "disappears" (and hence becomes "invalid"). In my own timezone, DST started at 2AM on Sunday 10th March, so that hour is invalid:



$ cat /etc/timezone
America/Toronto
$ date --date="2019-03-10 02:00:00"
date: invalid date ‘2019-03-10 02:00:00’


whereas the hours before and after are valid:



steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 01:00:00"
Sun Mar 10 01:00:00 EST 2019
steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 03:00:00"
Sun Mar 10 03:00:00 EDT 2019


In timezones where the change over happens at midnight, the bare date appears invalid because GNU date assumes a time of midnight:



$ TZ=Asia/Tehran date --date='2019-03-22'
date: invalid date ‘2019-03-22’


but one hour later is valid:



$ TZ=Asia/Tehran date --date='2019-03-22 01:00:00'
Fri Mar 22 01:00:00 +0430 2019





share|improve this answer













I'm almost sure this is due to the change over to daylight saving time in the given timezone: effectively this means that an hour "disappears" (and hence becomes "invalid"). In my own timezone, DST started at 2AM on Sunday 10th March, so that hour is invalid:



$ cat /etc/timezone
America/Toronto
$ date --date="2019-03-10 02:00:00"
date: invalid date ‘2019-03-10 02:00:00’


whereas the hours before and after are valid:



steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 01:00:00"
Sun Mar 10 01:00:00 EST 2019
steeldriver@xenial-vm:~/forums/tests/dir$ date --date="2019-03-10 03:00:00"
Sun Mar 10 03:00:00 EDT 2019


In timezones where the change over happens at midnight, the bare date appears invalid because GNU date assumes a time of midnight:



$ TZ=Asia/Tehran date --date='2019-03-22'
date: invalid date ‘2019-03-22’


but one hour later is valid:



$ TZ=Asia/Tehran date --date='2019-03-22 01:00:00'
Fri Mar 22 01:00:00 +0430 2019






share|improve this answer












share|improve this answer



share|improve this answer










answered 48 mins ago









steeldriversteeldriver

69.9k11114186




69.9k11114186












  • Thanks, adding time to date fixed the problem.

    – ICE
    3 mins ago


















  • Thanks, adding time to date fixed the problem.

    – ICE
    3 mins ago

















Thanks, adding time to date fixed the problem.

– ICE
3 mins ago






Thanks, adding time to date fixed the problem.

– ICE
3 mins ago














2














$ date_ascii="2019-03-22"
$ printf "%s" "$date_ascii" | od -c
0000000 2 0 1 9 - 0 3 - 2 2
0000012
$ TZ=Asia/Shanghai date -d "$date_ascii"
Fri Mar 22 00:00:00 America 2019


and



$ date_unicode="2019‑03‑22"
$ printf "%s" "$date_unicode" | od -c
0000000 2 0 1 9 342 200 221 0 3 342 200 221 2 2
0000016
$ TZ=Asia/Shanghai date -d "$date_unicode"
date: invalid date ‘2019‑03‑22’





share|improve this answer























  • Seems There is something wrong with timezone in my system :(

    – ICE
    4 hours ago















2














$ date_ascii="2019-03-22"
$ printf "%s" "$date_ascii" | od -c
0000000 2 0 1 9 - 0 3 - 2 2
0000012
$ TZ=Asia/Shanghai date -d "$date_ascii"
Fri Mar 22 00:00:00 America 2019


and



$ date_unicode="2019‑03‑22"
$ printf "%s" "$date_unicode" | od -c
0000000 2 0 1 9 342 200 221 0 3 342 200 221 2 2
0000016
$ TZ=Asia/Shanghai date -d "$date_unicode"
date: invalid date ‘2019‑03‑22’





share|improve this answer























  • Seems There is something wrong with timezone in my system :(

    – ICE
    4 hours ago













2












2








2







$ date_ascii="2019-03-22"
$ printf "%s" "$date_ascii" | od -c
0000000 2 0 1 9 - 0 3 - 2 2
0000012
$ TZ=Asia/Shanghai date -d "$date_ascii"
Fri Mar 22 00:00:00 America 2019


and



$ date_unicode="2019‑03‑22"
$ printf "%s" "$date_unicode" | od -c
0000000 2 0 1 9 342 200 221 0 3 342 200 221 2 2
0000016
$ TZ=Asia/Shanghai date -d "$date_unicode"
date: invalid date ‘2019‑03‑22’





share|improve this answer













$ date_ascii="2019-03-22"
$ printf "%s" "$date_ascii" | od -c
0000000 2 0 1 9 - 0 3 - 2 2
0000012
$ TZ=Asia/Shanghai date -d "$date_ascii"
Fri Mar 22 00:00:00 America 2019


and



$ date_unicode="2019‑03‑22"
$ printf "%s" "$date_unicode" | od -c
0000000 2 0 1 9 342 200 221 0 3 342 200 221 2 2
0000016
$ TZ=Asia/Shanghai date -d "$date_unicode"
date: invalid date ‘2019‑03‑22’






share|improve this answer












share|improve this answer



share|improve this answer










answered 4 hours ago









glenn jackmanglenn jackman

12.6k2545




12.6k2545












  • Seems There is something wrong with timezone in my system :(

    – ICE
    4 hours ago

















  • Seems There is something wrong with timezone in my system :(

    – ICE
    4 hours ago
















Seems There is something wrong with timezone in my system :(

– ICE
4 hours ago





Seems There is something wrong with timezone in my system :(

– ICE
4 hours ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1127834%2finvalid-date-error-by-date-command%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

acmart: Multiple authors: all with same affiliation, one author an additional affiliationHow to Write Names of Multiple Authors with Shared Affiliation in ACM 2017 Template?Multiple authors with different primary affiliation, but same additional affiliationSame affiliation for all authors without extra packagesIOS-Book-Article.cls: one author with multiple affiliationacmart: Shared Author AffiliationMultiple authors with different primary affiliation, but same additional affiliationAuthor affiliation with only 1 authorAdding Multiple Authors with Different Affiliation in LaTeX ArticleLaTeX: Multiple authors stays on same lineHow to Label Multiple Authors with Same DescriptionHow to make two authors use the same affiliationTwo authors with same affiliation on finished front page

How to write “ä” and other umlauts and accented letters in bibliography?Accents in BibTeXSorting references with special characters alphabeticallyUse ae ligature in bibliographyEastern European nameInverted circumflex in BibTexBibTex, non-ascii initials and nameptr fproblems with accent in LatexHow to add a Ø to my bibliography from Jabref?References without accentsTroubles when trying to cite St“omer-Verlet in ”title" field of a bib entryComprehensive list of accented charactersHow to type the letter “i” with two dots (diaeresis) in math mode?Problem with glossary text and accented lettersSpecial character in bibliographyAccented letters, Unicode and LaTeX accentsHow to stop natbib from modifying bibliography styleCitation of a paper with non-standard characters by BibtexWrite accented characters to file using writeHow to group the bibliography alphabetically, if some surnames start with “accented” characters?How can I automatically capitalize significant words in my bibliography?

Problem using RevTeX4-1 with “! Undefined control sequence. @bibitemShut”