lua - 如何在 Lua 中 os.date() 生成的日期中添加天数
问题描述
模块中调用date()
了一个lua函数。os
调用os.date()
将以以下格式给出当前日期和时间:Tue Aug 10 13:04:17 2021
.
这样做:os.date("%x")
给我们以下内容:08/10/21
.
是否可以操纵日期函数将天数添加到当前返回的日期时间/日期?类似于当您尝试使用.setDate()
mutator 将日期添加到 JavaScript 日期时发生的情况。我已经看过How to add days in given datetime in Lua,但这不是我想要实现的。
提前感谢您的帮助。
解决方案
使用os.time
和计算秒数:
t=os.time()
print(os.date("%c",t))
d=12
t=t+d*24*60*60
print(os.date("%c",t))
推荐阅读
- r - 在 Ubuntu 18.04 和 R 4.0.2 上安装 tidyr 时出错
- c++ - 如何突出显示忍者构建系统产生的错误?
- angular - Angular - 反应形式 valueChanges。避免嵌套订阅
- python - 分析按不同列分组的 2 列
- entity-framework - Microsoft EntityFramework Core CLI 安装 - nuget 异常
- vega - 使用“触发器”将信号插入到 Vega 数据中,被平面映射
- javascript - 如何在 JavaScript 中的动态样式中避免过渡
- python - 错误:未能将一些参考资料推送到“https://github.com/E-wave112/myadmissionportalsite2.git”
- java - Minecraft 1.15 Forge Bullet mod 未渲染
- typescript - 将来自其他对象的参数作为已定义类型打字稿中的参数传递。对象字面量只能指定已知属性,ts(2345)