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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:25:14+00:00 2026-05-21T00:25:14+00:00

I am using $jsdate = date(Y, m, d, strtotime(‘-1 month’, (strtotime($date)))); to convert my

  • 0

I am using

$jsdate = date("Y, m, d", strtotime('-1 month', (strtotime($date))));

to convert my dates from

2011-03-28
to
2011, 02, 28

Problem is this is producing unpredictable results. For example today I got

2011-03-28
converted to
2011, 02, 28  // OK

 AND

2011-03-29
to
2011, 03, 01 // not OK!

Does anyone know what’s wrong here? I wonder if the calculation is inaccurate because of the -1 month.

Is there a way of simply subtracting 1 from m in ...date("Y, m, d", ...?

MORE INFO:

My data needs to be formatted as JavaScript Date Object in which January is 0, Feb is 1, etc. Therefore there is not a need to specifically subtract 1 month but actually subtract 1 from the month integer. At the end, the resulting string is not supposed to be 1 month earlier, but actually the same date, represented using JS Date Object style. I believe @vprimachenko’s answer below is a good solution. I apologize if this wasn’t clear in my OP.

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-05-21T00:25:14+00:00Added an answer on May 21, 2026 at 12:25 am

    you might use

    $datee = explode('-',$date);
    if($datee[1]-- < 0) {
        $datee[1]=12;
        $datee[0]--;
    }
    $jsdate = implode(', ',$datee);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I retrieve a list of date from a DB using JS and ADO and
Using mercurial, I've run into an odd problem where a line from one committer
Tell me if anyone encountered this problem: I show on my page plot using
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
Using Flex 3, I would like to take an image snapshot such as this:
Using PHP, I can convert MySQL data or static table data to csv, Excel,
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
using file_get_contents , I open an Internet URL and get the contents of this
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
using VB.Net2010 I need to call a C# DLL The problem I have is

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.