Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1=2012-10-07
- 1=2012-10-08
- 1=2012-10-09
- 1=2012-10-10
- 2=2012-10-07
- 2=2012-10-08
- 2=2012-10-09
- 2=2012-10-10
- 3=2012-10-05
- 3=2012-10-06
- 3=2012-10-08
- 3=2012-10-09
- 3=2012-10-10
- 1 available from 7-10 October 2012 //I know this line need to use date("F Y",strtotime());
- 2 available from 7-10 October 2012
- 3 available from 5-10 October 2012
- $dates = array('2000-10-02', '2000-10-01', '2000-10-03');
- sort($dates);
- // prints "1-3 October 2000"
- echo date('j', strtotime(current($dates))) . '-'
- . date('j', strtotime(end($dates))) . ' '
- . date('F Y', strtotime(current($dates)));
- $dates = array(
- array(1, "2012-10-07"),
- array(1, "2012-10-08"),
- array(1, "2012-10-09"),
- array(1, "2012-10-10"),
- array(2, "2012-10-07"),
- array(2, "2012-10-08"),
- array(2, "2012-10-09"),
- array(2, "2012-10-10"),
- array(3, "2012-10-05"),
- array(3, "2012-10-06"),
- array(3, "2012-10-08"),
- array(3, "2012-10-09"),
- array(3, "2012-10-10")
- );
- $info = array();
- foreach($dates as $roominfo) {
- $time = strtotime($roominfo[1]);
- $room = $roominfo[0];
- if(!array_key_exists($roominfo[0], $info))
- $info[$room] = array($time, $time);
- if($time<$info[$room][0])
- $info[$room][0] = $time;
- if($time>$info[$room][1])
- $info[$room][1] = $time;
- }
- foreach($info as $roomId => $roomRange) {
- echo $roomId.' available from '.
- date('d', $roomRange[0]).' - '.
- date('d F Y', $roomRange[1]).' <br/>';
- }
- 1 available from 07 - 10 October 2012
- 2 available from 07 - 10 October 2012
- 3 available from 05 - 10 October 2012
- <?php
- $dates = array('2012-10-07','2012-10-10','2012-10-01');
- $stimes = array_map('strtotime',$dates);
- var_dump($dates);
- var_dump($stimes);
- echo date('F j, Y', min($stimes));
- echo "<br />n";
- echo date('F j, Y', max($stimes));
Add Comment
Please, Sign In to add comment