当前位置:网站首页>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
边栏推荐
- C # add multi line and multi column text watermark in word
- tga文件格式(波形声音文件格式)
- Share 25 useful JS single line codes
- 随机梯度下降法、牛顿法、冲量法、AdaGrad、RMSprop以及Adam优化过程和理解
- Proxy实现mysql读写分离
- [cloud native | learn kubernetes from scratch] VIII. Namespace resource quotas and labels
- Interpretation of repartitioned network structure in repvgg network [with code]
- When the V100 of mindpole 8 card is trained to 101 epochs, an error of reading data timeout is reported
- 9. < tag dynamic programming and subsequence, subarray> lt.718. Longest repeated subarray + lt.1143. Longest common subsequence
- When AI encounters life and health, Huawei cloud builds three bridges for them
猜你喜欢

YOLOv7论文部分解读【含自己的理解】

Univariate function integration_ Partial integral method

RepVGG网络中重参化网络结构解读【附代码】

When AI encounters life and health, Huawei cloud builds three bridges for them

【高等数学】【8】微分方程

tiktok如何破零播放?

当AI邂逅生命健康,华为云为他们搭建三座桥
![Summarize the level of intelligent manufacturing discussion [macro understanding]](/img/84/3addabdf857c562535a4085782d3e8.png)
Summarize the level of intelligent manufacturing discussion [macro understanding]

Advantages of network virtualization of various manufacturers

Rainbow plug-in extension: monitor MySQL based on MySQL exporter
随机推荐
10.< tag-动态规划和子序列, 子数组>lt.53. 最大子数组和 + lt.392. 判断子序列 dbc
股票软件开发
Connecting to the database warning establishing SSL connection without server's identity verification is not recommended
919. Complete binary tree inserter
PreScan快速入门到精通第十八讲之PreScan轨迹编辑的特殊功能
QML combines qsqltablemodel to dynamically load data MVC "recommended collection"
tga文件格式(波形声音文件格式)
Do you still have certificates to participate in the open source community?
EZDML reverse engineering import database analysis practical operation tutorial
导电滑环在机械设备方面的应用
Dataloader reports an error "default_collate: batch must contain tensors, numpy arrays, numbers, dicts" when pytorch trains the model
Security Basics 4 - regular expressions
RF、GBDT、XGboost特征选择方法「建议收藏」
Recommended system topic | Minet: cross domain CTR prediction
Six axis sensor use learning record
飞行器pid控制(旋翼飞控)
Application of conductive slip ring in mechanical equipment
Dataframe first performs grouping operation and then combines output
统信UOS下配置安装cocos2dx开发环境
Siemens-PLM-TeamCenter下载、安装、使用教程