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“)”

Quoting Keynes in a lecture

Does the Linux kernel need a file system to run?

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

Is this toilet slogan correct usage of the English language?

Why does the Sun have different day lengths, but not the gas giants?

X marks the what?

How to align my equation to left?

How to say when an application is taking the half of your screen on a computer

Fear of getting stuck on one programming language / technology that is not used in my country

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

Do we have to expect a queue for the shuttle from Watford Junction to Harry Potter Studio?

Can a college of swords bard use blade flourish on an OA from dissonant whispers?

Can I say "fingers" when referring to toes?

What to do if you miss a job interview (deliberately)?

Do the primes contain an infinite almost arithmetic progression?

Why Shazam when there is already Superman?

Are Captain Marvel's powers affected by Thanos' actions in Infinity War

Why is so much work done on numerical verification of the Riemann Hypothesis?

What are the advantages of simplicial model categories over non-simplicial ones?

Why is the "ls" command showing permissions of files in a FAT32 partition?

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

Invalid date error by date command

User Story breakdown - Technical Task + User Feature

Does malloc reserve more space while allocating memory?



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 5 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
    6 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
    6 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
    6 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 52 mins ago









steeldriversteeldriver

69.9k11114186




69.9k11114186












  • Thanks, adding time to date fixed the problem.

    – ICE
    6 mins ago


















  • Thanks, adding time to date fixed the problem.

    – ICE
    6 mins ago

















Thanks, adding time to date fixed the problem.

– ICE
6 mins ago






Thanks, adding time to date fixed the problem.

– ICE
6 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

瀋陽號驅逐艦 目录 接收與服役 配置反潛直升機 武進三型性能升級 歷史 除役 參考資料 外部連結 导航菜单Taiwan Air Power海疆老兵-陽字號驅逐艦沿革World Navies Today: Taiwan (Republic of China)DD-839 USS POWER

Memorizing the KeyboardThe Norwegian Foreman''If the B…''The Consonant EaterThe Cherry TreeElle Rend Le Coeur Plus AmoureuxFill in the blanks with the number in wordsState of the UnionFind the missing elementsCircuit DiagramWhat's the name of the game show?

名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局