您可以使用 AM/PM 将 24 小时时间字符串格式化为 12 小时时间字符串吗? [英] Can you format 24-hour time string into 12-hour time string with AM/PM?

查看:25
本文介绍了您可以使用 AM/PM 将 24 小时时间字符串格式化为 12 小时时间字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以 %H:%M 字符串格式(例如15:43")在 sqlite 中存储了一些时间值,但我想将它们以 12 小时格式与 AM/PM 指标(例如下午 3:43").这对 sqlite 是否可行(如果可以,如何实现),或者我是否需要在我的应用程序代码中执行此操作?

解决方案

除非您使用自己的 自定义函数,你必须这样做是代码.

sqlite 的 strftime 日期格式化函数仅支持其 C 对应项的一小部分,不足以你的问题.sqlite 也缺乏像 IF 或 CASE 这样的选择结构,使得简单的 if/else 变得不可能.>

I store some time values in sqlite in %H:%M string format (for example "15:43"), but I would like to get them out formatted in 12 hour format with AM/PM indicators (for example "3:43 PM"). Is this possible with sqlite (and if so, how), or do I need to do this in my application code?

解决方案

Unless you extend sqlite with your own custom function, you'll have to do this is code.

sqlite's strftime date formatting function only supports a small subset of its C counterpart, insufficient for your problem. sqlite also lacks a selection construct like IF or CASE, making simple if/else impossible.

这篇关于您可以使用 AM/PM 将 24 小时时间字符串格式化为 12 小时时间字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆