当前位置:网站首页>Formatdatetime explanation [easy to understand]
Formatdatetime explanation [easy to understand]
2022-07-25 20:05:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
describe
Returns an expression in date or time format .
grammar
FormatDateTime(Date[,NamedFormat])
FormatDateTime The function syntax has the following parts :
part | describe |
|---|---|
Date | Essential . The date expression to be formatted . |
NamedFormat | Optional . Numerical value , Indicates the date / The format used by time . If you ignore this value , Then use vbGeneralDate. |
Set the value
NamedFormat The setting values of parameters are as follows :
constant | value | describe |
|---|---|---|
vbGeneralDate | 0 | Show date and / Or time . If there is a date section , Display in short date format . If there is a time section , Display in long time format . If there are both , Both parts show . |
vbLongDate | 1 | Display the date in the long date format specified in the computer locale value . |
vbShortDate | 2 | Display the date in the short date format specified in the computer locale value . |
vbLongTime | 3 | Display the time in the time format specified in the computer locale value . |
vbShortTime | 4 | use 24 Hour format (hh:mm) Display time . |
Windows There are many time formats in , What long date 、 A short date , Two years 、 Four digit year and so on , stay Delphi Available in the FormatDateTime Function outputs these formats , Here's how to use it :
function FormatDateTime(const Format: string; DateTime: TDateTime): string;
Format Parameter is a formatted string .DateTime Is the time type . The return value is a formatted string , Point of view Format Instruction characters in parameters :
c Display time in short time format , That is, it is all the representation of numbers
FormatdateTime(‘c’,now);
Output is :2004-8-7 9:55:40
d Corresponds to the date in the time , If the date is one digit, one digit will be displayed , Two digits show two
FormatdateTime(‘d’,now);
The output may be 1~31
dd and d It means the same thing , But it is always displayed in two digits
FormatdateTime(‘dd’,now);
The output may be 01~31
ddd It shows the day of the week
FormatdateTime(‘ddd’,now);
Output is : Saturday
dddd and ddd It shows the same .
But the above two may be different in other countries .
ddddd Display year, month and day in short time format
FormatdateTime(‘ddddd’,now);
Output is :2004-8-7
dddddd Display year, month, and day in a long format
FormatdateTime(‘dddddd’,now);
Output is :2004 year 8 month 7 Japan
e/ee/eee/eeee Display the year in corresponding digits
FormatdateTime(‘ee’,now);
Output is :04 ( Express 04 year )
m/mm/mmm/mmmm Represents the month
FormatdateTime(‘m’,now);
Output is :8
FormatdateTime(‘mm’,now);
Output is 08
FormatdateTime(‘mmm’,now);
Output is August
FormatdateTime(‘mmmm’,now);
Output is August
and ddd/dddd equally , It may be different in other countries
yy/yyyy Indicate year
FormatdateTime(‘yy’,now);
Output is 04
FormatdateTime(‘yyyy’,now);
Output is 2004
h/hh,n/nn,s/ss,z/zzz Hours, respectively , branch , second , millisecond
t Display time in short time format
FormatdateTime(‘t’,now);
Output is 10:17
tt Display time in long format
FormatdateTime(‘tt’,now);
Output is 10:18:46
ampm Show morning or afternoon in a long format
FormatdateTime(‘ttampm’,now);
Output is :10:22:57 In the morning
If you want to in Format Add ordinary string , You can use double quotation marks to separate those characters with specific meanings , In this way, if the ordinary string contains special characters, it will not be displayed in time format :
FormatdateTime(‘”today is” c’,now);
Output is :today is 2004-8-7 10:26:58
You can also add ”-“ or ”\” To separate the dates :
FormatdateTime(‘”today is” yy-mm-dd’,now);
FormatdateTime(‘”today is” yy\mm\dd’,now);
Output is : today is 04-08-07
It can also be used. ”:” To separate the time
FormatdateTime(‘”today is” hh:nn:ss’,now);
Output is :today is 10:32:23
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/127536.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢

919. 完全二叉树插入器

一元函数积分学_分部积分法

Recommended system topic | Minet: cross domain CTR prediction

【神器】截图+贴图工具 Snipaste

Day7: ordered binary tree (binary search tree)

wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
Detailed evaluation of current popular redis visual management tools

PreScan快速入门到精通第十九讲之PreScan执行器配置、轨迹同步及非配多个轨迹

sentinel简单限流和降级demo问题记录

03-树1 树的同构
随机推荐
PyTorch 模型 onnx 文件的导出和调用
Notes - record a cannotfinddatasourceexception: dynamic datasource can not find primary datasource problem solving
03-树1 树的同构
Application of conductive slip ring in mechanical equipment
Apache MINA框架「建议收藏」
Mindspore1.1.1 source code compilation and installation -- errors in the core compilation stage
JVM(二十三) -- JVM运行时参数
Analysis of CMS station building system of common PHP in China
YOLOv7论文部分解读【含自己的理解】
高数_第3章重积分 学习体会与总结
谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞
wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
Cloud native guide: what is cloud native infrastructure
Oracle database download, installation, use tutorial and problem summary
sentinel简单限流和降级demo问题记录
QML combines qsqltablemodel to dynamically load data MVC "recommended collection"
[wp]ctfshow-web introductory information collection
Google pixel 6A off screen fingerprint scanner has major security vulnerabilities
飞行器pid控制(旋翼飞控)
4. Server startup of source code analysis of Nacos configuration center