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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:16:40+00:00 2026-06-11T19:16:40+00:00

I am a little stuck here how to write a code for current date

  • 0

I am a little stuck here how to write a code for current date of the server and validate them.

So basically on one file is the form.php and i have to write the code for current date of the server in dd/mm/yy and this can be edited by the user. The date should appear in a form format for example on the web browser should appear date: [23/9/2012].

and on the other file which is the process.php I have to validate the date.

so for my form.php this is what i wrote so far:

<html>
<body>
 <?php
    if (isset ($_POST["date"])){
    $date = date("d/m/y"($_POST["date"]));
    echo $date;
    }
?>
<form action="form.php" method="POST">
Date: <input type="text" name="date" value="Date" />

</form>
</body>
</html>

what it appear on the web browser for date is only date:[date] just the word date but not the date. I’ve been stuck for an hour for this.

  • 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-11T19:16:41+00:00Added an answer on June 11, 2026 at 7:16 pm

    You can do this with a regex:

        <?php
        if (isset($_POST['date']) && !empty($_POST['date'])) {
            $date = trim($_POST['date']);
        }
    
        $regex = '/^((([1-2][0-9])|([1-9]))/([2])/[0-9]{4})|((([1-2][0-9])|([1-9])|(3[0-1]))/((1[0-2])|([3-9])|([1]))/[0-9]{4})$/';
        if (preg_match($regex, $date)) {
            $disp_date = $date;
    
            //update the date in db
            $error = '';
        }
        else {
           $error = 'Invalid date format<br />';
    
           //get last date from db
           $disp_date = $date_from_db;
        }
        ?>
        <?=$error?>
        <form action="" method="POST">
            <input type="text" value="<?=$disp_date?>" name="date" />
            <input type="submit" value="Submit Date" />
        </form>
    

    How the regex works:
    DD/MM/YYYY:
    DD must be 1-31, MM 1-12 and YYYY a 4 digit num.

    Edit: Fixed the problem with February.

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

Sidebar

Related Questions

A little stuck here. I have a simple question I guess. Given the following
Im stuck with this little project in C# but basically my problem is this:
Here's a little piece of code I wrote to report variables with missing values
I am little bit stuck here .. I have a datatable as _ Dim
I'm a little stuck on what I'm pretty sure is an easy solution. Here's
I'm a little stuck here and could really use some help. It seems to
I am a little stuck. I have created almost everything in the picture below.
OK, i've been working with this for some time and I'm a little stuck.
I apologize for the subjectiveness of this question, but I am a little stuck
I am a little bit stuck up. First, I'll post the screenshot and then

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.