.sh文件获取当前时间戳
时间: 2023-11-03 20:55:05 浏览: 97
JavaScript 获取当前时间戳的代码
5星 · 资源好评率100%
要获取当前时间戳的.sh文件可以使用以下代码:
```
current=`date "+%Y-%m-%d %H:%M:%S"`
timeStamp=`date -d "$current" +%s`
currentTimeStamp=$((timeStamp*1000))
echo $currentTimeStamp
```
这段代码首先获取当前时间,并将其转换为时间戳(精确到秒),然后乘以1000转换为毫秒,最后输出当前时间戳。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [shell(25) : 获取时间戳](https://blog.csdn.net/Lxinccode/article/details/123110657)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [shell 时间戳计算](https://blog.csdn.net/weixin_43258559/article/details/121271031)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文