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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:09:57+00:00 2026-05-26T17:09:57+00:00

I am in the middle of setting up a basic CMS that allows the

  • 0

I am in the middle of setting up a basic CMS that allows the client to add articles to their mobile app. The CMS is coded in PHP and will use JSON to deliver the content to the mobile app.

Now my problem is there is an option to publish the article at a certain date, so I want to validate the date to check it is valid.

So to test possibilites I made a small script. I am using strtotime() to check the date is valid, my script is:

<?php

    $date[] = '2011-31-01';
    $date[] = '2011-02-31';

    foreach($date as $str) {
        if(strtotime($str) == false) {
            $result[] = '<p>[' . $str . '] Resulted in an <span style="color: red;">Error.</span></p>';
        } else {
            $result[] = '<p>[' . $str . '] Resulted in <span style="color: green;">Success.</span></p>';
        }
    }

    foreach($result as $return) {
        echo $return;
    }

?>

Now my problem is the date 2011-02-31 which is 31st February 2011 is returning as valid, when obviously it isn’t. So my question is why does it do this? and is there a better method to check that the date is valid and exists?

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-26T17:09:58+00:00Added an answer on May 26, 2026 at 5:09 pm

    checkdate(); Validates a Gregorian date. Returns TRUE if the date given is valid; otherwise returns FALSE.

     if(checkdate(2, 31, 2011)){
          echo "Yeah";
    
      } else {echo "nah";}
    

    It returns false!

    That’s the way to go.

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

Sidebar

Related Questions

Middle-tier component will execute the data access routines in application. The component will call
I am using Kohana 3 and using a middle controller named controller_Facebook that is
I'm in the middle of setting up PMD as a tool in our team
I need some help setting up a particular terrain. I have a world that
I have an application that is based on a UINavigationController; I wish to add
I have a structure that looks like this: http://peterned.home.xs4all.nl/examples/csslayout1.html - where the middle div
how would I go about setting up a page using divs and css that
I have this flash object that is being displayed in the middle of the
I am in the middle of a discussion with a colleague about the best
I'm in the middle of writing code in .Net to draw something in my

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.