Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android日期更改scipt不工作_Android_Date_Datetime_Sh - Fatal编程技术网

Android日期更改scipt不工作

Android日期更改scipt不工作,android,date,datetime,sh,Android,Date,Datetime,Sh,我写了一个简单的脚本来更改日期。当我在ADB中单独输入行时,它工作正常。当我在ADB中刷新脚本时,它会抛出错误(在Begging上带有@的历元编号)或错误地更改日期(2018年…)。代码如下: #!/system/bin/sh currentdate=$(busybox date +%s) currentdate=$(($currentdate + 5400)) currentdate=$(busybox date -d @$currentdate +"%Y%m%d.%H%M%S") date

我写了一个简单的脚本来更改日期。当我在ADB中单独输入行时,它工作正常。当我在ADB中刷新脚本时,它会抛出错误(在Begging上带有@的历元编号)或错误地更改日期(2018年…)。代码如下:

#!/system/bin/sh
currentdate=$(busybox date +%s)
currentdate=$(($currentdate + 5400))
currentdate=$(busybox date -d @$currentdate +"%Y%m%d.%H%M%S")
date -s $currentdate
我做错了什么?

请尝试以下代码

currentdate=$(busybox date +%s)
currentdate=$((currentdate+5400))
date -s $(busybox date -s @$currentdate '+%Y%m%d.%H%M%S')