The second part of the time to change the second part of the time to 0.

Source: Internet
Author: User

When an alarm is triggered using a local notification, the local notification is accurate to seconds. The second part of the time must be omitted during implementation.

I thought of the following method, and it was quite concise. The promotion can also be used to omit the hour part of the time.

Nsdate * oldtime = [nsdate date];
Nstimeinterval interval = oldtime. timeintervalsince1970;

// Divide interval minus interval by the remainder after 60. Nstimeinterval is actually of the double type, and % can only be used for the int type. Therefore, the fmod function is required.

Nsdate * nosecondtime = [nsdate datewithtimeintervalsince1970: interval-fmod (interval, 60)];

The second part of the time to change the second part of the time to 0.

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.