GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Feb-2004, 01:21
giobbi giobbi is offline
New Member
 
Join Date: Jan 2004
Posts: 14
giobbi is on a distinguished road

Date calculation - newbiequiz.


Hi all.
Trying to calculate a date from a variable but i cant get it to work. My variables and calculations looks like this:

PHP Code:

<?php
$conn = mysql_connect("localhost","root","xxx");

mysql_select_db("koncern",$conn);

$sql = "select * from avtal order by created desc";
$result = mysql_query( $sql, $conn ) or die(mysql_error()); 

while( $newArray = mysql_fetch_array($result) ) 
$id_avtal = $newArray['id_avtal'];
$created = $newArray['created'];
$name = $newArray['name'];
$signed = $newArray['signed']; // My date i want to calculate (2001-01-01)
$period = $newArray['period']; // Month i want to add to $signed (12)

$expired = mktime (0, 0, 0, date("Y"), date("m")+$period, date("d")); // add 12 month to 2001-01-01 and put it in $expired

$expired = date("Y m d", $expired); //Make it readable

echo "
<table border='1' cellspacing=2 cellpadding=3>
<tr>
    <td> ID </td>
    <td> Registrerat </td>
    <td> Namn </td>
    <td> Paskrivet datum </td>
    <td> Period </td>
    <td> Utgangsdatum </td>
</tr>
    
    <tr>
        <td> $id_avtal</td>
        <td> $created</td>
        <td> $name</td>
        <td> $signed</td>
        <td> $period</td>
        <td> $expired</td>
</table>
    ";
}
mysql_close($conn);
?>


The calculated date is 1969 12 31 and i don't know why.


My tables are:

+----------+-----------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------------+------+-----+---------------------+----------------+
| id_avtal | int(11) | | PRI | NULL | auto_increment |
| created | datetime | | | 0000-00-00 00:00:00 | |
| name | varchar(244) | YES | | NULL | |
| signed | date | | | 0000-00-00 | |
| period | int(4) unsigned | | | 0 | |
+----------+-----------------+------+-----+---------------------+----------------+

Whats wrong here?

/Piero
Last edited by dsmith : 28-Feb-2004 at 11:48. Reason: Use php tags for highlighting
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
leave calculation andy MySQL / PHP Forum 1 26-Jul-2003 11:10
count date skyloon MySQL / PHP Forum 2 01-Jul-2003 01:28
Easily keep up to date with the latest PHP news (and any other for that matter) jrobbio MySQL / PHP Forum 0 03-Jun-2003 03:54
Date for in an e-mail Allowee MySQL / PHP Forum 4 17-May-2003 09:05

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:35.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.