Format the date and time ctime () function in C Language

Source: Internet
Author: User

Format the date and time ctime () function in C Language

Function prototype: Char * ctime (const time_t * time );

Function Description:SetTime_tType date and time are converted into strings.

Return Value:ReturnsTMThe address of the string to which the date and time in the structure are converted. The format of the string is defined as follows::

Ddd Mmm dd hh: mm: SS yyyy

Meaning of each character:

DddA day of a week,For exampleMon

MmmMonth,For exampleJan

DdOne day in the month (1, 2 ,......, 31)

HHHour (1, 2 ,......, 24)

MmMinutes (1, 2 ,......, 59)

SSNumber of seconds (1, 2 ,......, 59)

YyyyYear

Example:Converts the current time and date to a string.

# Include

# Include

Int main ()

{

Time_t T;

Time (& T );

Printf ("% s \ n", ctime (& T ));

Return 0;

}

Original

Http://www.eefocus.com/xuefu2009/blog/10-04/188679_b2f1a.html

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.