date: invalid date trying to set linux date in specific format












0















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’









share|improve this question













migrated from serverfault.com 14 hours ago


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 do date 07041434. If you wanted to set the year say to 1969, then it would be date 070414341969

    – ron
    12 hours ago











  • 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
    12 hours ago


















0















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’









share|improve this question













migrated from serverfault.com 14 hours ago


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 do date 07041434. If you wanted to set the year say to 1969, then it would be date 070414341969

    – ron
    12 hours ago











  • 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
    12 hours ago
















0












0








0








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’









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 14 at 9:02









user63898user63898

146115




146115




migrated from serverfault.com 14 hours ago


This question came from our site for system and network administrators.






migrated from serverfault.com 14 hours ago


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 do date 07041434. If you wanted to set the year say to 1969, then it would be date 070414341969

    – ron
    12 hours ago











  • 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
    12 hours ago





















  • 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
    12 hours ago











  • 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
    12 hours ago



















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
12 hours ago





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
12 hours ago













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
12 hours ago







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
12 hours ago












1 Answer
1






active

oldest

votes


















1














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





share|improve this answer


























  • 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
    13 hours ago











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
});


}
});














draft saved

draft discarded


















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









1














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





share|improve this answer


























  • 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
    13 hours ago
















1














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





share|improve this answer


























  • 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
    13 hours ago














1












1








1







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





share|improve this answer















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






share|improve this answer














share|improve this answer



share|improve this answer








edited 14 hours ago

























answered Jan 14 at 9:33









Mr ShunzMr Shunz

3,44212025




3,44212025













  • 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
    13 hours ago



















  • 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
    13 hours ago

















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
13 hours ago





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
13 hours ago


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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

Loup dans la culture

How to solve the problem of ntp “Unable to contact time server” from KDE?

ASUS Zenbook UX433/UX333 — Configure Touchpad-embedded numpad on Linux