当前位置:网站首页>FormatDateTime说解[通俗易懂]
FormatDateTime说解[通俗易懂]
2022-07-25 19:59:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
描述
返回一个日期或时间格式的表达式。
语法
FormatDateTime(Date[,NamedFormat])
FormatDateTime函数语法有如下几部分:
部分 | 描述 |
|---|---|
Date | 必需的。要被格式化的日期表达式。 |
NamedFormat | 可选的。数字值,表示日期/时间所使用的格式。如果忽略该值,则使用vbGeneralDate。 |
设置值
NamedFormat参数的设置值如下:
常数 | 值 | 描述 |
|---|---|---|
vbGeneralDate | 0 | 显示日期和/或时间。如果有日期部分,则用短日期格式显示。如果有时间部分,则用长时间格式显示。如果都有,两部分都显示。 |
vbLongDate | 1 | 用计算机区域设置值中指定的长日期格式显示日期。 |
vbShortDate | 2 | 用计算机区域设置值中指定的短日期格式显示日期。 |
vbLongTime | 3 | 用计算机区域设置值中指定的时间格式显示时间。 |
vbShortTime | 4 | 用24小时格式(hh:mm)显示时间。 |
Windows中的时间格式还真不少,什么长日期、短日期,两位年份、四位年份等等,在Delphi中可用FormatDateTime函数输出这些格式,下面介绍它的用法:
function FormatDateTime(const Format: string; DateTime: TDateTime): string;
Format参数是一个格式化字符串。DateTime是时间类型。返回值是一种格式化后的字符串,重点来看Format参数中的指令字符:
c 以短时间格式显示时间,即全部是数字的表示
FormatdateTime(‘c’,now);
输出为:2004-8-7 9:55:40
d 对应于时间中的日期,日期是一位则显示一位,两位则显示两位
FormatdateTime(‘d’,now);
输出可能为1~31
dd 和d的意义一样,但它始终是以两位来显示的
FormatdateTime(‘dd’,now);
输出可能为01~31
ddd 显示的是星期几
FormatdateTime(‘ddd’,now);
输出为: 星期六
dddd 和ddd显示的是一样的。
但上面两个如果在其他国家可能不一样。
ddddd 以短时间格式显示年月日
FormatdateTime(‘ddddd’,now);
输出为:2004-8-7
dddddd 以长时间格式显示年月日
FormatdateTime(‘dddddd’,now);
输出为:2004年8月7日
e/ee/eee/eeee 以相应的位数显示年
FormatdateTime(‘ee’,now);
输出为:04 (表示04年)
m/mm/mmm/mmmm 表示月
FormatdateTime(‘m’,now);
输出为:8
FormatdateTime(‘mm’,now);
输出为 08
FormatdateTime(‘mmm’,now);
输出为 八月
FormatdateTime(‘mmmm’,now);
输出为 八月
和ddd/dddd 一样,在其他国家可能不同
yy/yyyy 表示年
FormatdateTime(‘yy’,now);
输出为 04
FormatdateTime(‘yyyy’,now);
输出为 2004
h/hh,n/nn,s/ss,z/zzz 分别表示小时,分,秒,毫秒
t 以短时间格式显示时间
FormatdateTime(‘t’,now);
输出为 10:17
tt 以长时间格式显示时间
FormatdateTime(‘tt’,now);
输出为10:18:46
ampm 以长时间格式显示上午还是下午
FormatdateTime(‘ttampm’,now);
输出为:10:22:57上午
如果要在Format中加普通的字符串,可以用双引号隔开那些特定义的字符,这样普通字符串中如果含特殊的字符就不会被显示为时间格式啦:
FormatdateTime(‘”today is” c’,now);
输出为:today is 2004-8-7 10:26:58
时间中也可以加”-“或”\”来分开日期:
FormatdateTime(‘”today is” yy-mm-dd’,now);
FormatdateTime(‘”today is” yy\mm\dd’,now);
输出为: today is 04-08-07
也可以用”:”来分开时间
FormatdateTime(‘”today is” hh:nn:ss’,now);
输出为:today is 10:32:23
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/127536.html原文链接:https://javaforall.cn
边栏推荐
- PreScan快速入门到精通第十九讲之PreScan执行器配置、轨迹同步及非配多个轨迹
- wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
- 「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求
- Beihang and other "deep learning event extraction" literature review paper, 27 page PDF describes the current trend
- PMP practice once a day | don't get lost in the exam -7.25
- 数字信息化(先枚举假设,再看是否满足条件)(1089 狼人杀-简单版)
- 参与开源社区还有证书拿?
- wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
- JVM(二十三) -- JVM运行时参数
- [wp]ctfshow-web getting started - Explosion
猜你喜欢

wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M

Day7: ordered binary tree (binary search tree)

Beihang and other "deep learning event extraction" literature review paper, 27 page PDF describes the current trend

9.< tag-动态规划和子序列, 子数组>lt.718. 最长重复子数组 + lt.1143. 最长公共子序列

Research and application of servo driver in robot

Export and call of onnx file of pytorch model

Recommended system topic | Minet: cross domain CTR prediction

Stochastic gradient descent method, Newton method, impulse method, adagrad, rmsprop and Adam optimization process and understanding

Creative drop-down multi choice JS plug-in download

滑雪手机端H5小游戏源码下载
随机推荐
C语言学习日记3——realloc函数
Common misunderstandings caused by a time reporting assistant of Blue Bridge Cup basic questions
Wechat applet 10 - wechat template
分享 25 个有用的 JS 单行代码
Siemens PLM Teamcenter download, installation and use tutorial
Binarysearch basic binary search
Beihang and other "deep learning event extraction" literature review paper, 27 page PDF describes the current trend
From Tong Dai to "Tong Dai" and then to brand, the beauty of sudden profits has changed and remained unchanged
随机梯度下降法、牛顿法、冲量法、AdaGrad、RMSprop以及Adam优化过程和理解
Mutual conversion of camera internal parameter matrix K and FOV
Typeerror: 'STR' object is not callable error reason
Summarize the level of intelligent manufacturing discussion [macro understanding]
Shopping guide for high-end flagship projectors: dangbei X3 pro and dangbei F5 are more immersive!
[wp]ctfshow-web入门-爆破
10. < tag dynamic programming and subsequence, subarray> lt.53. maximum subarray and + lt.392. Judge subsequence DBC
一元函数积分学_分部积分法
当AI邂逅生命健康,华为云为他们搭建三座桥
PreScan快速入门到精通第十八讲之PreScan轨迹编辑的特殊功能
Software designer afternoon real topic: 2009-2022
Creative drop-down multi choice JS plug-in download