date: invalid date trying to set linux date in specific format
Clash Royale CLAN TAG#URR8PPP
i try to set linux date & time in specific format but it keep giving me error
Example :
date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
or
date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
keep giving me this error :
date: invalid date ‘19-01-2017 00:05:01’
linux time date
migrated from serverfault.com Jan 17 at 15:13
This question came from our site for system and network administrators.
add a comment |
i try to set linux date & time in specific format but it keep giving me error
Example :
date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
or
date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
keep giving me this error :
date: invalid date ‘19-01-2017 00:05:01’
linux time date
migrated from serverfault.com Jan 17 at 15:13
This question came from our site for system and network administrators.
I always just do MMDDhhmm, provided i don't need to change the existing year. So for July 4 at 2:34pm you would dodate 07041434
. If you wanted to set the year say to 1969, then it would bedate 070414341969
– ron
Jan 17 at 16:47
if you doman date
you will see that format defined such as[MMDDhhmm[[CC]YY][.ss]]
The [ ] means optional. So if you did justdate 1434
then you would be trying to set the month and day not the hour and minute. So if your date command requires MMDDhhmm then to simply set the time you always have to give 2-digit month and 2-digit day first before the 2-digit hour and 2-digit minute.
– ron
Jan 17 at 16:50
add a comment |
i try to set linux date & time in specific format but it keep giving me error
Example :
date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
or
date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
keep giving me this error :
date: invalid date ‘19-01-2017 00:05:01’
linux time date
i try to set linux date & time in specific format but it keep giving me error
Example :
date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
or
date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
keep giving me this error :
date: invalid date ‘19-01-2017 00:05:01’
linux time date
linux time date
asked Jan 14 at 9:02
user63898user63898
146115
146115
migrated from serverfault.com Jan 17 at 15:13
This question came from our site for system and network administrators.
migrated from serverfault.com Jan 17 at 15:13
This question came from our site for system and network administrators.
I always just do MMDDhhmm, provided i don't need to change the existing year. So for July 4 at 2:34pm you would dodate 07041434
. If you wanted to set the year say to 1969, then it would bedate 070414341969
– ron
Jan 17 at 16:47
if you doman date
you will see that format defined such as[MMDDhhmm[[CC]YY][.ss]]
The [ ] means optional. So if you did justdate 1434
then you would be trying to set the month and day not the hour and minute. So if your date command requires MMDDhhmm then to simply set the time you always have to give 2-digit month and 2-digit day first before the 2-digit hour and 2-digit minute.
– ron
Jan 17 at 16:50
add a comment |
I always just do MMDDhhmm, provided i don't need to change the existing year. So for July 4 at 2:34pm you would dodate 07041434
. If you wanted to set the year say to 1969, then it would bedate 070414341969
– ron
Jan 17 at 16:47
if you doman date
you will see that format defined such as[MMDDhhmm[[CC]YY][.ss]]
The [ ] means optional. So if you did justdate 1434
then you would be trying to set the month and day not the hour and minute. So if your date command requires MMDDhhmm then to simply set the time you always have to give 2-digit month and 2-digit day first before the 2-digit hour and 2-digit minute.
– ron
Jan 17 at 16:50
I always just do MMDDhhmm, provided i don't need to change the existing year. So for July 4 at 2:34pm you would do
date 07041434
. If you wanted to set the year say to 1969, then it would be date 070414341969
– ron
Jan 17 at 16:47
I always just do MMDDhhmm, provided i don't need to change the existing year. So for July 4 at 2:34pm you would do
date 07041434
. If you wanted to set the year say to 1969, then it would be date 070414341969
– ron
Jan 17 at 16:47
if you do
man date
you will see that format defined such as [MMDDhhmm[[CC]YY][.ss]]
The [ ] means optional. So if you did just date 1434
then you would be trying to set the month and day not the hour and minute. So if your date command requires MMDDhhmm then to simply set the time you always have to give 2-digit month and 2-digit day first before the 2-digit hour and 2-digit minute.– ron
Jan 17 at 16:50
if you do
man date
you will see that format defined such as [MMDDhhmm[[CC]YY][.ss]]
The [ ] means optional. So if you did just date 1434
then you would be trying to set the month and day not the hour and minute. So if your date command requires MMDDhhmm then to simply set the time you always have to give 2-digit month and 2-digit day first before the 2-digit hour and 2-digit minute.– ron
Jan 17 at 16:50
add a comment |
1 Answer
1
active
oldest
votes
The issue looks like to be your "date string", i.e. "19-01-2017 00:05:01"
.
From the man page:
The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or
"2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day,
time zone, day of week, relative time, relative date, and numbers.
Now, "a mostly free format human readable date" is a bit vague, and looks like 19-01-2017
is not readable. Probably because it might be unparseable in cases like 02-03-2019
(is it March, 02 or February, 03?).
Try changing it to ISO format:
$> date "+%d-%m-%C%y %H:%M:%S" -d "2017-01-19 00:05:01"
19-01-2017 00:05:01
o use a format like the example found in the man page:
$> date "+%d-%m-%C%y %H:%M:%S" -d "19 Jan 2017 00:05:01"
19-01-2017 00:05:01
The info pages (as recommended by the brief entry in the manpage) can expand on that "probably": when the month is a number, the date will be interpreted as either "year-month-day", or the US-style "month/day(/optional year)".
– JigglyNaga
Jan 17 at 16:30
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f495088%2fdate-invalid-date-trying-to-set-linux-date-in-specific-format%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The issue looks like to be your "date string", i.e. "19-01-2017 00:05:01"
.
From the man page:
The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or
"2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day,
time zone, day of week, relative time, relative date, and numbers.
Now, "a mostly free format human readable date" is a bit vague, and looks like 19-01-2017
is not readable. Probably because it might be unparseable in cases like 02-03-2019
(is it March, 02 or February, 03?).
Try changing it to ISO format:
$> date "+%d-%m-%C%y %H:%M:%S" -d "2017-01-19 00:05:01"
19-01-2017 00:05:01
o use a format like the example found in the man page:
$> date "+%d-%m-%C%y %H:%M:%S" -d "19 Jan 2017 00:05:01"
19-01-2017 00:05:01
The info pages (as recommended by the brief entry in the manpage) can expand on that "probably": when the month is a number, the date will be interpreted as either "year-month-day", or the US-style "month/day(/optional year)".
– JigglyNaga
Jan 17 at 16:30
add a comment |
The issue looks like to be your "date string", i.e. "19-01-2017 00:05:01"
.
From the man page:
The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or
"2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day,
time zone, day of week, relative time, relative date, and numbers.
Now, "a mostly free format human readable date" is a bit vague, and looks like 19-01-2017
is not readable. Probably because it might be unparseable in cases like 02-03-2019
(is it March, 02 or February, 03?).
Try changing it to ISO format:
$> date "+%d-%m-%C%y %H:%M:%S" -d "2017-01-19 00:05:01"
19-01-2017 00:05:01
o use a format like the example found in the man page:
$> date "+%d-%m-%C%y %H:%M:%S" -d "19 Jan 2017 00:05:01"
19-01-2017 00:05:01
The info pages (as recommended by the brief entry in the manpage) can expand on that "probably": when the month is a number, the date will be interpreted as either "year-month-day", or the US-style "month/day(/optional year)".
– JigglyNaga
Jan 17 at 16:30
add a comment |
The issue looks like to be your "date string", i.e. "19-01-2017 00:05:01"
.
From the man page:
The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or
"2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day,
time zone, day of week, relative time, relative date, and numbers.
Now, "a mostly free format human readable date" is a bit vague, and looks like 19-01-2017
is not readable. Probably because it might be unparseable in cases like 02-03-2019
(is it March, 02 or February, 03?).
Try changing it to ISO format:
$> date "+%d-%m-%C%y %H:%M:%S" -d "2017-01-19 00:05:01"
19-01-2017 00:05:01
o use a format like the example found in the man page:
$> date "+%d-%m-%C%y %H:%M:%S" -d "19 Jan 2017 00:05:01"
19-01-2017 00:05:01
The issue looks like to be your "date string", i.e. "19-01-2017 00:05:01"
.
From the man page:
The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or
"2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day,
time zone, day of week, relative time, relative date, and numbers.
Now, "a mostly free format human readable date" is a bit vague, and looks like 19-01-2017
is not readable. Probably because it might be unparseable in cases like 02-03-2019
(is it March, 02 or February, 03?).
Try changing it to ISO format:
$> date "+%d-%m-%C%y %H:%M:%S" -d "2017-01-19 00:05:01"
19-01-2017 00:05:01
o use a format like the example found in the man page:
$> date "+%d-%m-%C%y %H:%M:%S" -d "19 Jan 2017 00:05:01"
19-01-2017 00:05:01
edited Jan 17 at 15:18
answered Jan 14 at 9:33
Mr ShunzMr Shunz
3,47712127
3,47712127
The info pages (as recommended by the brief entry in the manpage) can expand on that "probably": when the month is a number, the date will be interpreted as either "year-month-day", or the US-style "month/day(/optional year)".
– JigglyNaga
Jan 17 at 16:30
add a comment |
The info pages (as recommended by the brief entry in the manpage) can expand on that "probably": when the month is a number, the date will be interpreted as either "year-month-day", or the US-style "month/day(/optional year)".
– JigglyNaga
Jan 17 at 16:30
The info pages (as recommended by the brief entry in the manpage) can expand on that "probably": when the month is a number, the date will be interpreted as either "year-month-day", or the US-style "month/day(/optional year)".
– JigglyNaga
Jan 17 at 16:30
The info pages (as recommended by the brief entry in the manpage) can expand on that "probably": when the month is a number, the date will be interpreted as either "year-month-day", or the US-style "month/day(/optional year)".
– JigglyNaga
Jan 17 at 16:30
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f495088%2fdate-invalid-date-trying-to-set-linux-date-in-specific-format%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
I always just do MMDDhhmm, provided i don't need to change the existing year. So for July 4 at 2:34pm you would do
date 07041434
. If you wanted to set the year say to 1969, then it would bedate 070414341969
– ron
Jan 17 at 16:47
if you do
man date
you will see that format defined such as[MMDDhhmm[[CC]YY][.ss]]
The [ ] means optional. So if you did justdate 1434
then you would be trying to set the month and day not the hour and minute. So if your date command requires MMDDhhmm then to simply set the time you always have to give 2-digit month and 2-digit day first before the 2-digit hour and 2-digit minute.– ron
Jan 17 at 16:50