Skip to content

Instantly share code, notes, and snippets.

@arif98741
Last active March 8, 2018 19:53
Show Gist options
  • Save arif98741/1bb621ed9e0d76453eb42d7dfab5ce01 to your computer and use it in GitHub Desktop.
Save arif98741/1bb621ed9e0d76453eb42d7dfab5ce01 to your computer and use it in GitHub Desktop.
Date Moth Year Concat in PHP
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div class="form-group col-sm-3 ">
<?php
if (isset($_POST['submit'])) {
$date = $_POST['date'];
$month = $_POST['month'];
$year = $_POST['year'];
$formattd_date = $date. "-". $month. "-". $year;
}
?>
<form action="" class="form-control" method="POST">
<label>Date de naissance: <?php if (isset($formattd_date)) {echo $formattd_date; } ?></label> </br>
<select name="date">
<?php
for($i = 1; $i<=31; $i++) { ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php } ?>
</select>
<select name="month">
<?php
$months = array(
"January", "February", "March", "April", "May","June","July",
"August", "September", "October", "November", "December"
);
foreach($months as $value) {
?>
<option value="<?php echo $value; ?>"><?php echo $value; ?></option>
<?php } ?>
</select>
<select name="year">
<?php
for($i = 1940; $i<=date("Y"); $i++) { ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php } ?>
</select>
<input type="submit" class="form-control" name="submit" value="Submit">
</form>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment