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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












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 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 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
















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 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 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














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 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 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


















  • 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

















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











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
    Jan 17 at 16:30










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
    Jan 17 at 16:30















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
    Jan 17 at 16:30













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 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

















  • 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

















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

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay