Embedded poky linux, no ntpdate available.

It looks like none of the following commands is suitable:

# date -s "$(curl -s --head http://google.com | grep '^Date:' | cut -d' ' -f 3-)" 
date: invalid date '08 Mar 2021 13:22:34 GMT'
# date -s "$(curl -s --head http://google.com | grep '^Date:' | cut -d' ' -f 3-6)"
date: invalid date '08 Mar 2021 13:22:34'
#date +"%d %b %Y %H:%M:%S" -s "$(curl -s --head http://google.com | grep '^Date:' | cut -d' ' -f 3-6)"
date: invalid date '08 Mar 2021 13:22:34'


BusyBox date only accepts the following date formats:

YYYY-MM-DD hh:mm[:ss]

If the -D option is available in the BusyBox version you are using, you can use this command as suggested by steeldriver:

busybox date -d '08 Mar 2021 13:22:34' -D '%d %b %Y %H:%M:%S'
  • 1
    What is the date implementation on your system (GNU? busybox? something else?) Mar 8, 2021 at 13:43
  • Yes, BusyBox v1.24.1
    – sephiroth
    Mar 8, 2021 at 13:48
  • 1
    At least with my version of busybox (v1.27.2), the date command has a -D option for specifying the format of the -d datestring ex. busybox date -d '08 Mar 2021 13:22:34' -D '%d %b %Y %H:%M:%S' - not sure if that's available in v1.24.1? Mar 8, 2021 at 14:08
  • Sadly not. If I run busybox date -d '08 Mar 2021 13:22:34' -D '%d %b %Y %H:%M:%S', i get date: invalid option -- 'D'
    – sephiroth
    Mar 8, 2021 at 14:10
  • I guess there's no simple way around hacking it with a script
    – sephiroth
    Mar 8, 2021 at 14:13

2 Answers 2


Maybe you could update busybox. I got V1.30 and the command works


In the end I parsed the time string from google to put it in a busybox date friendly format (YYYY-mm-dd HH:MM:SS). Hopefully someone will find this useful in the future.


monthnumber() {
    printf "%02d\n" $monthnumber

G_DATE="$(curl -s --head http://google.com | grep '^Date:' | cut -d' ' -f 3-6)"
G_SPLIT=($(echo $G_DATE | tr " "))

BB_DATE="${G_SPLIT[2]}-$(monthnumber ${G_SPLIT[1]})-${G_SPLIT[0]} ${G_SPLIT[3]}"

date -s "$BB_DATE"

monthnumber() function was taken from https://stackoverflow.com/a/41385862/9815377

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.