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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:08:48+00:00 2026-06-09T06:08:48+00:00

Comment is the output I’m seeing. Help! echo date(Y-m-t, strtotime(2012-07-31 -1 month)); //2012-07-31 echo

  • 0

Comment is the output I’m seeing. Help!

echo date("Y-m-t", strtotime("2012-07-31 -1 month")); //2012-07-31
echo date("Y-m-t", strtotime("2012-07-31 -2 month")); //2012-05-31

July has 31 days, so it can’t be processing it as August 1, right? Even if it were, the second line should work. Right?!

Thanks!

  • 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-06-09T06:08:49+00:00Added an answer on June 9, 2026 at 6:08 am

    What’s happening here is, “7-31” minus one month comes out as “6-31”, which translates to “7-1”, which – asking for the last day of the month – comes out as “7-31”.

    When you want to do month math, it’s almost always, if not always, better to build the time using mktime.

    $month = 7;
    echo date("Y-m-t", mktime(0, 0, 0, $month - 1, 1, 2012)); //2012-06-30
    

    Note that when doing month math in mktime, always give ‘1’ as the day. Or really anything as long as it’s 28 or lower.

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

Sidebar

Related Questions

How do I output the [Comment][title]s one after another in this array? Array (
I don't see synchronized output when i comment the the line wait(1) in thread()
function get() { $.post( 'postchatfame.php', { comment: postchatfamemsg.comment.value, userid: postchatfamemsg.userid.value }, function(output) { $('#walls').html(output).show();
I just wondering how can I split a large XML output of Nokogiri For
XML file - <Remarks> <Remark> <Cid>2009-1</Cid> <Date>3-11-2011 2:55:0</Date> <Title>Book</Title> <Comment>XXX</Comment> </Remark> <Remark> <Cid>2009-2</Cid> <Date>3-12-2011
When i running my app output shows me a lot of this strings: 2012-05-12
I am trying comment a multiline section of xml to an output file using
I created a nested comment library for Codeigniter and it's almost working. I can't
Why the following code produces different output for me? <% @comments.each do |comment| %>
How can I comment on each line of the following lines from a script?

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.