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“)”
System.QueryException unexpected token
How could a planet have erratic days?
Mixing PEX brands
It grows, but water kills it
Using substitution ciphers to generate new alphabets in a novel
Creepy dinosaur pc game identification
Can a college of swords bard use blade flourish on an OA from dissonant whispers?
Why would a new[] expression ever invoke a destructor?
This is why we puzzle
Why does the Sun have different day lengths, but not the gas giants?
Can I still be respawned if I die by falling off the map?
Multiplicative persistence
Did arcade monitors have same pixel aspect ratio as TV sets?
How should I respond when I lied about my education and the company finds out through background check?
Terse Method to Swap Lowest for Highest?
How do apertures which seem too large to physically fit work?
Why "had" in "[something] we would have made had we used [something]"?
When were female captains banned from Starfleet?
Mimic lecturing on blackboard, facing audience
Non-trope happy ending?
PTIJ: Haman's bad computer
Calculate sum of polynomial roots
Can I say "fingers" when referring to toes?
Angel of Condemnation - Exile creature with second ability
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“)”
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:
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
add a comment |
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:
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
Comments are not for extended discussion; this conversation has been moved to chat.
– Thomas Ward♦
5 hours ago
add a comment |
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:
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
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:
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
command-line date
edited 8 hours ago
ICE
asked 9 hours ago
ICEICE
8473724
8473724
Comments are not for extended discussion; this conversation has been moved to chat.
– Thomas Ward♦
5 hours ago
add a comment |
Comments are not for extended discussion; this conversation has been moved to chat.
– Thomas Ward♦
5 hours ago
Comments are not for extended discussion; this conversation has been moved to chat.
– Thomas Ward♦
5 hours ago
Comments are not for extended discussion; this conversation has been moved to chat.
– Thomas Ward♦
5 hours ago
add a comment |
2 Answers
2
active
oldest
votes
I'm almost sure this is due to the changeover 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 times immediately before and after are valid:
$ date --date="2019-03-10 01:59:59"
Sun Mar 10 01:59:59 EST 2019
$ 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
See also Invalid Date Linux
Thanks, adding time to date fixed the problem.
– ICE
3 hours ago
They "change to daylight saving at midnight" should not be a problem for 2019-03-22 as the users TZ is currently PDT.
– glenn jackman
2 hours ago
add a comment |
$ 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’
Seems There is something wrong with timezone in my system :(
– ICE
7 hours ago
you should reinstall thetzdata
package.
– glenn jackman
2 hours ago
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
I'm almost sure this is due to the changeover 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 times immediately before and after are valid:
$ date --date="2019-03-10 01:59:59"
Sun Mar 10 01:59:59 EST 2019
$ 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
See also Invalid Date Linux
Thanks, adding time to date fixed the problem.
– ICE
3 hours ago
They "change to daylight saving at midnight" should not be a problem for 2019-03-22 as the users TZ is currently PDT.
– glenn jackman
2 hours ago
add a comment |
I'm almost sure this is due to the changeover 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 times immediately before and after are valid:
$ date --date="2019-03-10 01:59:59"
Sun Mar 10 01:59:59 EST 2019
$ 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
See also Invalid Date Linux
Thanks, adding time to date fixed the problem.
– ICE
3 hours ago
They "change to daylight saving at midnight" should not be a problem for 2019-03-22 as the users TZ is currently PDT.
– glenn jackman
2 hours ago
add a comment |
I'm almost sure this is due to the changeover 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 times immediately before and after are valid:
$ date --date="2019-03-10 01:59:59"
Sun Mar 10 01:59:59 EST 2019
$ 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
See also Invalid Date Linux
I'm almost sure this is due to the changeover 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 times immediately before and after are valid:
$ date --date="2019-03-10 01:59:59"
Sun Mar 10 01:59:59 EST 2019
$ 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
See also Invalid Date Linux
edited 2 hours ago
answered 3 hours ago
steeldriversteeldriver
69.9k11114186
69.9k11114186
Thanks, adding time to date fixed the problem.
– ICE
3 hours ago
They "change to daylight saving at midnight" should not be a problem for 2019-03-22 as the users TZ is currently PDT.
– glenn jackman
2 hours ago
add a comment |
Thanks, adding time to date fixed the problem.
– ICE
3 hours ago
They "change to daylight saving at midnight" should not be a problem for 2019-03-22 as the users TZ is currently PDT.
– glenn jackman
2 hours ago
Thanks, adding time to date fixed the problem.
– ICE
3 hours ago
Thanks, adding time to date fixed the problem.
– ICE
3 hours ago
They "change to daylight saving at midnight" should not be a problem for 2019-03-22 as the users TZ is currently PDT.
– glenn jackman
2 hours ago
They "change to daylight saving at midnight" should not be a problem for 2019-03-22 as the users TZ is currently PDT.
– glenn jackman
2 hours ago
add a comment |
$ 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’
Seems There is something wrong with timezone in my system :(
– ICE
7 hours ago
you should reinstall thetzdata
package.
– glenn jackman
2 hours ago
add a comment |
$ 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’
Seems There is something wrong with timezone in my system :(
– ICE
7 hours ago
you should reinstall thetzdata
package.
– glenn jackman
2 hours ago
add a comment |
$ 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’
$ 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’
answered 7 hours ago
glenn jackmanglenn jackman
12.6k2545
12.6k2545
Seems There is something wrong with timezone in my system :(
– ICE
7 hours ago
you should reinstall thetzdata
package.
– glenn jackman
2 hours ago
add a comment |
Seems There is something wrong with timezone in my system :(
– ICE
7 hours ago
you should reinstall thetzdata
package.
– glenn jackman
2 hours ago
Seems There is something wrong with timezone in my system :(
– ICE
7 hours ago
Seems There is something wrong with timezone in my system :(
– ICE
7 hours ago
you should reinstall the
tzdata
package.– glenn jackman
2 hours ago
you should reinstall the
tzdata
package.– glenn jackman
2 hours ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Comments are not for extended discussion; this conversation has been moved to chat.
– Thomas Ward♦
5 hours ago