首页主机资讯日期格式 FormatDateTime函数详解

日期格式 FormatDateTime函数详解

时间2023-11-13 13:13:03发布访客分类主机资讯浏览812
导读:FormatDateTime函数是一种常用的操作日期格式的函数,它用于将指定的日期值转换为指定的日期格式。语法:FormatDateTime(date, format 参数:- date:要格式化的日期值。- format:指定的日期格式。...

FormatDateTime函数是一种常用的操作日期格式的函数,它用于将指定的日期值转换为指定的日期格式。
语法:
FormatDateTime(date, format)
参数:
- date:要格式化的日期值。
- format:指定的日期格式。可以是以下几种格式之一:
- "d":短日期格式,仅显示日期。
- "D":长日期格式,显示日期和星期。
- "t":短时间格式,仅显示时间。
- "T":长时间格式,显示时间和秒。
- "f":长日期+短时间格式。
- "F":长日期+长时间格式。
- "g":短日期+短时间格式。
- "G":短日期+长时间格式。
- "M":月份和日期格式。
- "R":RFC1123格式,如"ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"。
- "s":可排序日期和时间格式,如"yyyy'-'MM'-'dd'T'HH':'mm':'ss"。
- "u":通用可排序日期和时间格式,如"yyyy'-'MM'-'dd HH':'mm':'ss'Z'"。
- "U":通用可排序日期和时间格式,如"yyyy'-'MM'-'dd HH':'mm':'ss'Z'"(UTC时间)。
- "Y":年份和月份格式。
返回值:
返回格式化后的日期字符串。
示例:
- FormatDateTime(#2022-01-01#, "d") 返回 "1/1/2022"
- FormatDateTime(#2022-01-01#, "D") 返回 "Saturday, January 1, 2022"
- FormatDateTime(#2022-01-01 12:34:56#, "t") 返回 "12:34 PM"
- FormatDateTime(#2022-01-01 12:34:56#, "T") 返回 "12:34:56 PM"
- FormatDateTime(#2022-01-01 12:34:56#, "f") 返回 "Saturday, January 1, 2022 12:34 PM"
- FormatDateTime(#2022-01-01 12:34:56#, "F") 返回 "Saturday, January 1, 2022 12:34:56 PM"
- FormatDateTime(#2022-01-01 12:34:56#, "g") 返回 "1/1/2022 12:34 PM"
- FormatDateTime(#2022-01-01 12:34:56#, "G") 返回 "1/1/2022 12:34:56 PM"
- FormatDateTime(#2022-01-01#, "M") 返回 "January 1"
- FormatDateTime(#2022-01-01#, "R") 返回 "Sat, 01 Jan 2022 00:00:00 GMT"
- FormatDateTime(#2022-01-01#, "s") 返回 "2022-01-01T00:00:00"
- FormatDateTime(#2022-01-01#, "u") 返回 "2022-01-01 00:00:00Z"
- FormatDateTime(#2022-01-01#, "U") 返回 "2022-01-01 00:00:00Z"
- FormatDateTime(#2022-01-01#, "Y") 返回 "January, 2022"

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

详解

若转载请注明出处: 日期格式 FormatDateTime函数详解
本文地址: https://pptw.com/jishu/537441.html
Java中List的简述 android付费框架 android框架原理

游客 回复需填写必要信息