Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created August 29, 2013 10:00
Show Gist options
  • Save phpfiddle/6376279 to your computer and use it in GitHub Desktop.
Save phpfiddle/6376279 to your computer and use it in GitHub Desktop.
daytodayMCA140
<?php
function getDates($from_date, $to_date){
$dates = array();
$step = '+1 day';
$format = 'm/d/Y';
$current = strtotime($from_date);
$to_date = strtotime($to_date);
while( $current <= $to_date ) {
$dates[] = date($format, $current);
$current = strtotime($step, $current);
}
return $dates;
// Implement the logic for listing the Days from given range of dates and also prints the day of the date
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
if(isset($_POST['from_date']) && isset($_POST['to_date'])){
extract($_POST);
$dates = getDates($from_date,$to_date);
?>
<table>
<tr><th>Date</th><th>Day</th></tr>
<?php
// Display the Dates with day here
?>
</table>
<?php
} else{
?>
<h3>My form</h3>
<form method="post">
<label>From (mm/dd/yyyy)</label> <input type="text" value="<?php echo date('m/d/Y');?>" size="30" maxlength="100" placeholder="mm/dd/yyyy" name="from_date" /><br />
<label>To(mm/dd/yyyy)</label> <input type="text" value="<?php echo date('m/d/Y',strtotime('+1 day',time()));?>" size="30" maxlength="100" placeholder="mm/dd/yyyy" name="to_date" /><br />
<button id="mysubmit" type="submit">Submit</button><br /><br />
</form>
<?php
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment