datetime - sqlalchemy中的时间戳操作
问题描述
我正在尝试比较两个时间戳,例如x
和y
,其中 y 应该是当前时间戳减去一定的秒数s
,例如y = sa.func.current_timestamp() - s
。但似乎这y
不是一个时间戳。如何将其转换为时间戳?
示例代码
def foo(x, y):
# x is a timestamp, y is number of seconds
y = sa.func.current_timestamp() - y
return x > y
解决方案
推荐阅读
- gitlab - 如何使用 GITLAB 功能标志在 CI yml 文件中按顺序运行同一阶段的作业
- angular - 安装后导入 vega-embed
- github - 无法删除 Github 存储库
- javascript - 如何让我的汉堡菜单 JavaScript 工作?
- visual-studio-code - 为什么 VSCode 的用户安装程序这么小?
- typescript - 使用 wasm_bindgen 返回 typescript union
- z3 - 操作 Z3 数据结构的方法?
- authentication - fetchUserRecord 用于前端登录给出typo3 错误
- javascript - JSON.stringify() 以便对象字段位于一行
- flutter - 键盘出现时如何向上移动TextField?