date command in busybox not accepting formatted input date
Clash Royale CLAN TAG#URR8PPP
I want to set the date using busybox's date
command (BusyBox v1.21.0).
My custom date to which I want to set the computer is of this form:
Tue, 15 Jan 2019 10:46:13 GMT
What my date
command is capable of is to print out the date in the same format using this string:
date +"%a, %d %b %Y %T %Z"
It returns the date in the exact same format as above.
But It would not accept this when I use the -s
option to set the date.
This fails for example:
date -u +"%a, %d %b %Y %T %Z" -s "Wed, 17 Feb 2010 19:14:32 UTC"
date: invalid date 'Wed, 17 Feb 2010 19:14:32 UTC'
I know busybox commands are reduced in function, but I imagined that when it can handle the format string to print the current date in the desired form, then it should also be able to use it to interpret an input string.
date busybox
add a comment |
I want to set the date using busybox's date
command (BusyBox v1.21.0).
My custom date to which I want to set the computer is of this form:
Tue, 15 Jan 2019 10:46:13 GMT
What my date
command is capable of is to print out the date in the same format using this string:
date +"%a, %d %b %Y %T %Z"
It returns the date in the exact same format as above.
But It would not accept this when I use the -s
option to set the date.
This fails for example:
date -u +"%a, %d %b %Y %T %Z" -s "Wed, 17 Feb 2010 19:14:32 UTC"
date: invalid date 'Wed, 17 Feb 2010 19:14:32 UTC'
I know busybox commands are reduced in function, but I imagined that when it can handle the format string to print the current date in the desired form, then it should also be able to use it to interpret an input string.
date busybox
add a comment |
I want to set the date using busybox's date
command (BusyBox v1.21.0).
My custom date to which I want to set the computer is of this form:
Tue, 15 Jan 2019 10:46:13 GMT
What my date
command is capable of is to print out the date in the same format using this string:
date +"%a, %d %b %Y %T %Z"
It returns the date in the exact same format as above.
But It would not accept this when I use the -s
option to set the date.
This fails for example:
date -u +"%a, %d %b %Y %T %Z" -s "Wed, 17 Feb 2010 19:14:32 UTC"
date: invalid date 'Wed, 17 Feb 2010 19:14:32 UTC'
I know busybox commands are reduced in function, but I imagined that when it can handle the format string to print the current date in the desired form, then it should also be able to use it to interpret an input string.
date busybox
I want to set the date using busybox's date
command (BusyBox v1.21.0).
My custom date to which I want to set the computer is of this form:
Tue, 15 Jan 2019 10:46:13 GMT
What my date
command is capable of is to print out the date in the same format using this string:
date +"%a, %d %b %Y %T %Z"
It returns the date in the exact same format as above.
But It would not accept this when I use the -s
option to set the date.
This fails for example:
date -u +"%a, %d %b %Y %T %Z" -s "Wed, 17 Feb 2010 19:14:32 UTC"
date: invalid date 'Wed, 17 Feb 2010 19:14:32 UTC'
I know busybox commands are reduced in function, but I imagined that when it can handle the format string to print the current date in the desired form, then it should also be able to use it to interpret an input string.
date busybox
date busybox
asked Jan 15 at 11:00
tzippytzippy
15116
15116
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
busybox date
only accepts very specific time formats, not arbitrary ones.
$ busybox date --help
[...]
[-s,--set] TIME Set time to TIME
[...]
Recognized TIME formats:
hh:mm[:ss]
[YYYY.]MM.DD-hh:mm[:ss]
YYYY-MM-DD hh:mm[:ss]
[[[[[YY]YY]MM]DD]hh]mm[.ss]
'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead
So you'll just have to write it like, date -s 2010.02.17-19:14:32
(or whichever format you prefer).
thanks! So there's no way of getting my date's month (for example `'Jan') into the date command?
– tzippy
Jan 15 at 12:14
not unless you provide your own script that translates your arbitrary date format into one understood by busybox date. date can output most formats fine, just doesn't accept them as input when setting date.
– frostschutz
Jan 15 at 13:24
Got it. That's what I'm doing now with a script that returns the month's number when given the 3 digit string.
– tzippy
Jan 15 at 13:26
add a comment |
You can get busybox date to do the conversion of formats for you, using -D
to specify the input format, and the usual +...
for the output format, with -d
providing the reference date and time. For example,
r='Tue, 15 Jan 2019 09:16:53 GMT'
d=$(busybox date -d "$r" -D "%a, %d %b %Y %T %Z" +'%Y-%m-%d %H:%M:%S')
# d becomes 2019-16-15 09:01:53
busybox date -s "$d"
Amazing! (and now I have to find out why this doesn't work with ArchLinux busybox)
– frostschutz
Jan 16 at 20:19
1
OK, for whatever reason, ArchLinux busybox does not accept%Z
indate -D
. Works fine otherwise.
– frostschutz
Jan 16 at 20:29
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%2f494581%2fdate-command-in-busybox-not-accepting-formatted-input-date%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
busybox date
only accepts very specific time formats, not arbitrary ones.
$ busybox date --help
[...]
[-s,--set] TIME Set time to TIME
[...]
Recognized TIME formats:
hh:mm[:ss]
[YYYY.]MM.DD-hh:mm[:ss]
YYYY-MM-DD hh:mm[:ss]
[[[[[YY]YY]MM]DD]hh]mm[.ss]
'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead
So you'll just have to write it like, date -s 2010.02.17-19:14:32
(or whichever format you prefer).
thanks! So there's no way of getting my date's month (for example `'Jan') into the date command?
– tzippy
Jan 15 at 12:14
not unless you provide your own script that translates your arbitrary date format into one understood by busybox date. date can output most formats fine, just doesn't accept them as input when setting date.
– frostschutz
Jan 15 at 13:24
Got it. That's what I'm doing now with a script that returns the month's number when given the 3 digit string.
– tzippy
Jan 15 at 13:26
add a comment |
busybox date
only accepts very specific time formats, not arbitrary ones.
$ busybox date --help
[...]
[-s,--set] TIME Set time to TIME
[...]
Recognized TIME formats:
hh:mm[:ss]
[YYYY.]MM.DD-hh:mm[:ss]
YYYY-MM-DD hh:mm[:ss]
[[[[[YY]YY]MM]DD]hh]mm[.ss]
'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead
So you'll just have to write it like, date -s 2010.02.17-19:14:32
(or whichever format you prefer).
thanks! So there's no way of getting my date's month (for example `'Jan') into the date command?
– tzippy
Jan 15 at 12:14
not unless you provide your own script that translates your arbitrary date format into one understood by busybox date. date can output most formats fine, just doesn't accept them as input when setting date.
– frostschutz
Jan 15 at 13:24
Got it. That's what I'm doing now with a script that returns the month's number when given the 3 digit string.
– tzippy
Jan 15 at 13:26
add a comment |
busybox date
only accepts very specific time formats, not arbitrary ones.
$ busybox date --help
[...]
[-s,--set] TIME Set time to TIME
[...]
Recognized TIME formats:
hh:mm[:ss]
[YYYY.]MM.DD-hh:mm[:ss]
YYYY-MM-DD hh:mm[:ss]
[[[[[YY]YY]MM]DD]hh]mm[.ss]
'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead
So you'll just have to write it like, date -s 2010.02.17-19:14:32
(or whichever format you prefer).
busybox date
only accepts very specific time formats, not arbitrary ones.
$ busybox date --help
[...]
[-s,--set] TIME Set time to TIME
[...]
Recognized TIME formats:
hh:mm[:ss]
[YYYY.]MM.DD-hh:mm[:ss]
YYYY-MM-DD hh:mm[:ss]
[[[[[YY]YY]MM]DD]hh]mm[.ss]
'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead
So you'll just have to write it like, date -s 2010.02.17-19:14:32
(or whichever format you prefer).
answered Jan 15 at 11:40
frostschutzfrostschutz
26.7k15583
26.7k15583
thanks! So there's no way of getting my date's month (for example `'Jan') into the date command?
– tzippy
Jan 15 at 12:14
not unless you provide your own script that translates your arbitrary date format into one understood by busybox date. date can output most formats fine, just doesn't accept them as input when setting date.
– frostschutz
Jan 15 at 13:24
Got it. That's what I'm doing now with a script that returns the month's number when given the 3 digit string.
– tzippy
Jan 15 at 13:26
add a comment |
thanks! So there's no way of getting my date's month (for example `'Jan') into the date command?
– tzippy
Jan 15 at 12:14
not unless you provide your own script that translates your arbitrary date format into one understood by busybox date. date can output most formats fine, just doesn't accept them as input when setting date.
– frostschutz
Jan 15 at 13:24
Got it. That's what I'm doing now with a script that returns the month's number when given the 3 digit string.
– tzippy
Jan 15 at 13:26
thanks! So there's no way of getting my date's month (for example `'Jan') into the date command?
– tzippy
Jan 15 at 12:14
thanks! So there's no way of getting my date's month (for example `'Jan') into the date command?
– tzippy
Jan 15 at 12:14
not unless you provide your own script that translates your arbitrary date format into one understood by busybox date. date can output most formats fine, just doesn't accept them as input when setting date.
– frostschutz
Jan 15 at 13:24
not unless you provide your own script that translates your arbitrary date format into one understood by busybox date. date can output most formats fine, just doesn't accept them as input when setting date.
– frostschutz
Jan 15 at 13:24
Got it. That's what I'm doing now with a script that returns the month's number when given the 3 digit string.
– tzippy
Jan 15 at 13:26
Got it. That's what I'm doing now with a script that returns the month's number when given the 3 digit string.
– tzippy
Jan 15 at 13:26
add a comment |
You can get busybox date to do the conversion of formats for you, using -D
to specify the input format, and the usual +...
for the output format, with -d
providing the reference date and time. For example,
r='Tue, 15 Jan 2019 09:16:53 GMT'
d=$(busybox date -d "$r" -D "%a, %d %b %Y %T %Z" +'%Y-%m-%d %H:%M:%S')
# d becomes 2019-16-15 09:01:53
busybox date -s "$d"
Amazing! (and now I have to find out why this doesn't work with ArchLinux busybox)
– frostschutz
Jan 16 at 20:19
1
OK, for whatever reason, ArchLinux busybox does not accept%Z
indate -D
. Works fine otherwise.
– frostschutz
Jan 16 at 20:29
add a comment |
You can get busybox date to do the conversion of formats for you, using -D
to specify the input format, and the usual +...
for the output format, with -d
providing the reference date and time. For example,
r='Tue, 15 Jan 2019 09:16:53 GMT'
d=$(busybox date -d "$r" -D "%a, %d %b %Y %T %Z" +'%Y-%m-%d %H:%M:%S')
# d becomes 2019-16-15 09:01:53
busybox date -s "$d"
Amazing! (and now I have to find out why this doesn't work with ArchLinux busybox)
– frostschutz
Jan 16 at 20:19
1
OK, for whatever reason, ArchLinux busybox does not accept%Z
indate -D
. Works fine otherwise.
– frostschutz
Jan 16 at 20:29
add a comment |
You can get busybox date to do the conversion of formats for you, using -D
to specify the input format, and the usual +...
for the output format, with -d
providing the reference date and time. For example,
r='Tue, 15 Jan 2019 09:16:53 GMT'
d=$(busybox date -d "$r" -D "%a, %d %b %Y %T %Z" +'%Y-%m-%d %H:%M:%S')
# d becomes 2019-16-15 09:01:53
busybox date -s "$d"
You can get busybox date to do the conversion of formats for you, using -D
to specify the input format, and the usual +...
for the output format, with -d
providing the reference date and time. For example,
r='Tue, 15 Jan 2019 09:16:53 GMT'
d=$(busybox date -d "$r" -D "%a, %d %b %Y %T %Z" +'%Y-%m-%d %H:%M:%S')
# d becomes 2019-16-15 09:01:53
busybox date -s "$d"
answered Jan 15 at 21:35
meuhmeuh
31.9k11954
31.9k11954
Amazing! (and now I have to find out why this doesn't work with ArchLinux busybox)
– frostschutz
Jan 16 at 20:19
1
OK, for whatever reason, ArchLinux busybox does not accept%Z
indate -D
. Works fine otherwise.
– frostschutz
Jan 16 at 20:29
add a comment |
Amazing! (and now I have to find out why this doesn't work with ArchLinux busybox)
– frostschutz
Jan 16 at 20:19
1
OK, for whatever reason, ArchLinux busybox does not accept%Z
indate -D
. Works fine otherwise.
– frostschutz
Jan 16 at 20:29
Amazing! (and now I have to find out why this doesn't work with ArchLinux busybox)
– frostschutz
Jan 16 at 20:19
Amazing! (and now I have to find out why this doesn't work with ArchLinux busybox)
– frostschutz
Jan 16 at 20:19
1
1
OK, for whatever reason, ArchLinux busybox does not accept
%Z
in date -D
. Works fine otherwise.– frostschutz
Jan 16 at 20:29
OK, for whatever reason, ArchLinux busybox does not accept
%Z
in date -D
. Works fine otherwise.– frostschutz
Jan 16 at 20:29
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%2f494581%2fdate-command-in-busybox-not-accepting-formatted-input-date%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