asp.net in asp.net, m$ provides us with an object called DateTime, which we use to get the current time. Like what:
DateTime Dt=datetime.now;
In the above program we made a 24 time object called DT, if we want to get a 12-system time object, we can use another statement
DateTime Dt=datetime.today;
But whether it's now or today, the time we get is just a 2001-03-27t00:57:09 time figure. Perhaps in general this time is sufficient (for example, we're just getting the current time, but in real life we need more than just this big string of numbers, we need to get the exact number of seconds, minutes, moments, and so on, and then this whole bunch of numbers isn't all we need, The ASP's time function also provides us with objects such as Second,minute,hour, but in asp.net, this is not. I have seen friends in order to get a specific minute, and write a function of the DateTime.Now string separated from the time you want. When we do not know the use of datetime, there is no way to do so.
Fortunately, m$ provides the format method for us, using our ability to quickly get the time format we want.
The Format method is:
public string Format (
string format,
Iserviceobjectprovider SP
);
Format refers to the formatting we specify, it has a lot of values, I have to list:
Standard format format formats
D mm/dd/yyyy (2001-3-27)
D dddd, MMMM DD, yyyy such as (March 27, 2001)
F dddd, MMMM dd, yyyy hh:mm (March 27, 2001 0:00)
F dddd, MMMM dd, yyyy HH:mm:ss (March 27, 2001 0:00:00)
G mm/dd/yyyy hh:mm (2001-3-27-0:00)
G mm/dd/yyyy HH:mm:ss (2001-3-27-0:00:00)
M, M MMMM DD (March 27)
R, R ddd, dd MMM yyyy HH ': ' mm ': ' ss ' GMT ' such as (Mon, Mar 2001 16:00:00 GMT)
S yyyy-mm-dd HH:mm:ss seems to be unable to use
T hh:mm as (0:00)
T HH:mm:ss as (0:00:00)
U yyyy-mm-dd HH:mm:ss (2001-03-26 16:00:00z)
U dddd, MMMM dd, yyyy HH:mm:ss (March 26, 2001 16:00:00)
Y, y MMMM, yyyy (March 2001)
Custom formatting list format pattern Description
D such as: 2001-3-27
DD such as: 27
DDD: Monday
dddd: Monday (full name)
M as: March 27
MM such as: 03
MMM such as: March
MMMM such as: March (full name)
Y: March 2001
yy such as: 01
yyyy such as: 2001
GG such as: A.D.
HH, hh* such as: 12
HH, hh* such as: 00
M as: March 27
MM, mm* such as: 00 (min)
S such as: 2001-03-27t00:00:00
SS, ss* such as: 00 (sec)
T such as: 0:00
TT, tt* such as: morning
The following is an example of a simple operation.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service