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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:38:44+00:00 2026-06-09T20:38:44+00:00

Im trying to to set up a php date validation (MM/DD/YYYY) but I’m having

  • 0

Im trying to to set up a php date validation (MM/DD/YYYY) but I’m having issues. Here is a sample of what I got:

$date_regex = '%\A(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d\z%'; 

$test_date = '03/22/2010'; 
if (preg_match($date_regex, $test_date,$_POST['birthday']) ==true) {
    $errors[] = 'user name most have no spaces';`
  • 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-09T20:38:46+00:00Added an answer on June 9, 2026 at 8:38 pm

    You could use checkdate. For example, something like this:

    $test_date = '03/22/2010';
    $test_arr  = explode('/', $test_date);
    if (checkdate($test_arr[0], $test_arr[1], $test_arr[2])) {
        // valid date ...
    }
    

    A more paranoid approach, that doesn’t blindly believe the input:

    $test_date = '03/22/2010';
    $test_arr  = explode('/', $test_date);
    if (count($test_arr) == 3) {
        if (checkdate($test_arr[0], $test_arr[1], $test_arr[2])) {
            // valid date ...
        } else {
            // problem with dates ...
        }
    } else {
        // problem with input ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically am trying to set a time and a date in PHP then set
i'm simply trying to get the current date in PHP, but it's getting '07:45:23'
I'm trying to use PHP in the terminal under MAMP but I got an
I'm trying to create a calendar class in php and am having issues returning
I am trying to set up a PHP path to my Zend Framework. I
I'm trying to set up some exotic PHP code (I'm not an expert), and
I'm trying to set up a batch file to automatically deploy a php app
Trying to learn about php's arrays today. I have a set of arrays like
I'm trying to upload a picture to a specific website using php cURL but
I am having issues trying to figure out how, to create an html input

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.