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 4589736
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:07:43+00:00 2026-05-21T22:07:43+00:00

I execute following snippet of code: NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *comp =

  • 0

I execute following snippet of code:

NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comp = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:[NSDate date]]; 
[comp setDay:1]; 

NSDate *firstDayOfMonthDate = [gregorian dateFromComponents:comp];

The Value of firstDayOfMonthDate is = 30-4-2011 but excpeted is 1-5-2011 i.e I want first date of month of any specified date.
But it gives me the last date of the previous month.

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-21T22:07:44+00:00Added an answer on May 21, 2026 at 10:07 pm

    Add

    [gregorian setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
    

    after initializing your NSCalendar.

    [NSDate date] will return a date in the UTC timezone, well an absolute interval since January 1, 2001 00:00 GMT, but the NSCalendar has its timeZone set to the default timezone which may not be UTC.

    UTC is the “same” as UTC, a quote from wikipedia:

    In casual use, when fractions of a
    second are not important, Greenwich
    Mean Time (GMT) can be considered
    equivalent to UTC or UT1. Saying “GMT”
    often implies either UTC or UT1 when
    used within informal or casual
    contexts. In technical contexts, usage
    of “GMT” is avoided; the unambiguous
    terminology “UTC” or “UT1” is
    preferred.[3]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to execute the following code snippet which creates a new site from
When I am trying to execute following code to email the contact form details,
I found the following code snippet here : with TClipper.Create do try AddPolygon(subject, ptSubject);
I have the following code snippet: PreparedStatement preparedStatement = connection.prepareStatement(sql); for (int i =
I have following code snippet in my application activity. If user is landing on
Consider the following code snippet: var count = 0; function a(req, res, next){ count++;
I have the following code snippet in QML, but I doubt statements inside Repeater
Im using the following code snippet .append( $('<td>').append( $('<a>').attr({ href: '#', class: 'assDelete', dataassetid:
The following snippet uses simple Java code. package pkg; final public class Main {
The following code snippet is taken page 112 of the book by Francesco Cesarini

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.