Jump to content

Convert date format


billy_111

Recommended Posts

Hey,

 

I am using a calendar on this page: http://www.glofamily.com/glo/about-us/, which can be seen in the right panel.

 

If you click on a day, it takes you to a page like so:

 

http://www.glofamily.com/glo/general-courses/?day=2 June 2010

 

Now i want to be able to have the link to be like this: ?day=02 June 2010 so i need to change the way the links work on the calendar, i tried using number_format but had no luck.

 

This is my code for the calendar, where do i need to change the code to achieve this?

 

	 <div id="calendar" class="right">
	<?php 
		$date = (!isset($_GET['month']) && !isset($_GET['year'])) ? time() : strtotime($_GET['month'] . '/1/' . $_GET['year']);

		$day = date('d', $date) ;
		$month = date('m', $date) ;
		$year = date('Y', $date) ;

		$first_day = mktime(0,0,0,$month, 1, $year) ;
		$title = date('F', $first_day) ; 
		$day_of_week = date('D', $first_day) ; 

		switch($day_of_week){ 
			case "Sun": $blank = 0; break; 
			case "Mon": $blank = 1; break; 
			case "Tue": $blank = 2; break; 
			case "Wed": $blank = 3; break; 
			case "Thu": $blank = 4; break; 
			case "Fri": $blank = 5; break; 
			case "Sat": $blank = 6; break; 
		}

		$days_in_month = cal_days_in_month(0, $month, $year) ; 
	?>

	 <div id="php-calendar" class="right">
	 <table>
	 <?php if(isset($_GET['ID']) && isset($_GET['c'])){
	 	echo "<tr><th colspan=7><a href=\"?ID=".$_GET['ID']."&c=".$_GET['c']."&month=". ($month - 1) . "&year=$year\"><<</a> $title $year <a href=\"?ID=".$_GET['ID']."&c=".$_GET['c']."&month=" . ($month + 1) . "&year=$year\">>></a></th></tr>"; 
	 } else {
	 	echo "<tr><th colspan=7><a href=\"?month=". ($month - 1) . "&year=$year\"><<</a> $title $year <a href=\"?month=" . ($month + 1) . "&year=$year\">>></a></th></tr>"; 
	 }
	 ?>
	 <tr><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>

	<?php
	 $day_count = 1;

	 echo "<tr>";

	 while ( $blank > 0 ) 
	 { 
		 echo "<td></td>"; 
		 $blank = $blank-1; 
		 $day_count++;
	 } 

	 $day_num = 1;

	 while ( $day_num <= $days_in_month ) 
	 { 
		 echo "<td> <a href='../general-courses/?day=$day_num $title $year'>$day_num</a></td>"; 
		 $day_num++; 
		 $day_count++;

		 if ($day_count > 7)
		 {
		 echo "</tr><tr>";
		 $day_count = 1;
		 }
	 } 

	 while ( $day_count >1 && $day_count <=7 ) 
	 { 
	 echo "<td> </td>"; 
	 $day_count++; 
	 } 
	 ?> 

	</table>		
	</div> 
	</div> 

 

Can you guys help me out?

 

Thanks again

Billy

Link to comment
https://forums.phpfreaks.com/topic/203865-convert-date-format/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.