The use of the nsdate of the 7.Foundation frame

Source: Internet
Author: User

The NSDate object is used to represent a specific point in time.

1 #import<Foundation/Foundation.h>2 3 intMainintargcConst Char*argv[]) {4 @autoreleasepool {5         //String Turn Time6NSString *time =@"2020/10/01 08:00:00";7NSDateFormatter *dateformat =[[NSDateFormatter alloc] init];8Dateformat.dateformat =@"YYY/MM/DD HH:mm:ss";9NSDate *date =[DateFormat datefromstring:time];TenNSLog (@"%@", date); One     } A     return 0; - } -  the /** Simple use of nsdate*/ - voidUse () - { -     //creation Time +NSDate *date =[NSDate Date]; -      +     //the time to print is Greenwich Mean Time (Beijing in the East 8 district) ANSLog (@"%@", date); at      -NSDate *date2 = [NSDate datewithtimeinterval:5Sincedate:date]; -      -     //description of the walk from 1970 onwards -Nstimeinterval seconds =[Date2 timeIntervalSince1970]; -NSLog (@"%f", seconds); in      - [Date2 Timeintervalsincenow]; to      + } -  the  * /** Time Turn string*/ $ voiddate2string ()Panax Notoginseng { -NSDate *date =[NSDate Date]; the      +     //Date Formatting class ANSDateFormatter *formatter =[[NSDateFormatter alloc] init]; the      +     //y year M month D Day -     //m min S second h (24) H (12) $Formatter.dateformat =@"YYY-MM-DD HH:mm:ss"; $NSString *str =[Formatter stringfromdate:date]; -NSLog (@"%@", str); -}

The use of the nsdate of the 7.Foundation frame

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.