|
|
#1 |
|
New Member
![]() Join Date: May 2011
Posts: 4
|
I am a teacher that uses HTML to provide simulations for my students. The simulations have a chronological date time line. Every time I want to use the simulation I have to go in and change all the dates to keep the realistic time line. I started reading about php and what to change the dates dynamically. My simulations on on a local server and do not go outside my class room.
Since dates appear many times in my simulations on many different pages, I am looking for code that works in with the fewest lines of code. The code will almost always be in a table cell. This simple example works for yesterday's date. Code:
<body>
<?php
date_default_timezone_set("America/Chicago");
$today = time();
$day = 86400 ;
?>
<table>
<tr>
<td><?php
$newdate = $today - ($day *1);
echo date("m/d/y", $newdate);
?>
</td>
</tr>
</table>
</body>
|
|
|
|
|
|
#2 |
|
Gold Member
![]() Join Date: Oct 2008
Location: Ireland
Posts: 349
|
to get the current date you could use something like this:
Code:
<body>
<?php
date_default_timezone_set("America/Chicago");
?>
<table>
<tr>
<td><?php
echo date( "m/d/y" );
?>
</td>
</tr>
</table>
</body>
__________________
Conor |
|
|
|
|
|
#3 |
|
Silver Member
![]() Join Date: Aug 2011
Posts: 100
|
If your function is to appear in many different files I would have one php file called date_inc.php and put your date code in it something like:
PHP Code:
PHP Code:
__________________
Mark R Wubbleyou - Web Design Newcastle A professional web design agency based in Newcastle upon Tyne servicing clients based throughout the U.K. Home spray tan machine - Landlord Reviews |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|