Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3617058
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:34:31+00:00 2026-05-18T22:34:31+00:00

I have implemented one iphone application in which i want to get last date

  • 0

I have implemented one iphone application in which i want to get last date of current month.
I don’t know how it possible.

Please help me for this question.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:34:32+00:00Added an answer on May 18, 2026 at 10:34 pm

    This ought to work:

    #import <Foundation/Foundation.h>
    
    NSDate *lastOfMonth(NSDate *today)
    {
        // get a gregorian calendar
        NSCalendar *calendar=[[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
    
        // get current month and year
        NSDateComponents *components=[calendar components:NSMonthCalendarUnit|NSYearCalendarUnit fromDate:today];
        NSInteger month=[components month];
        NSInteger year=[components year];
    
        // set components to first day of next month
        if (month==12) {
            [components setYear:year+1];
            [components setMonth:1];
        }
        else {
            [components setMonth:month+1];
        }
        [components setDay:1];
    
        // get last day of this month by subtracting 1 day (86400 seconds) from first of next
        return [[calendar dateFromComponents:components] dateByAddingTimeInterval:-86400];
    }
    
    int main (int argc, const char * argv[]) {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
        // the date tocay
        NSDate *today=[NSDate date];
        NSLog(@"today: %@", today);
        NSLog(@"last of month: %@", lastOfMonth(today));    
    
        [pool drain];
        return 0;
    }
    

    result:

    2010-12-23 11:20:36.499 so[46812:a0f] today: 2010-12-23 11:20:36 +0000
    2010-12-23 11:20:36.501 so[46812:a0f] last of month: 2010-12-31 00:00:00 +0000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a small iPhone application in which I have implemented the database
I have implemented product management system.I want to add one new features in which
I have implemented game application.In which i want to animate some area of images
I want to implement singleten design pattern in iphone code I have one array.
I have kind of Listing application for iPhone application, which always calling a web
I have an iPhone application that is mostly using standard controls. There is one
I am impementing one iphone and ipad applcation in which i want to implement
I have created one application in iphone sdk. i have already taken user credit
Possible Duplicate: Push-Notification Badge auto increment. I have implemented Push Notification for my iPhone
Do any one have idea for finding true direction using iPhone? I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.