Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date addition 1

Status
Not open for further replies.

ftsw

Technical User
Sep 17, 2002
9
0
0
US
Allowed to vote once per year.I have an attribute in a table called ung_sur_date that is a timestamp(12) datatype.
I am using mysql database and php.
My code:
$oneDay = 86400;
echo&quot;seconds per day is $oneDay <br><br>&quot;;

$today = date( &quot;U&quot; );
echo&quot;today is $today<br> &quot;;
echo date( &quot;F d, Y&quot;, $today );
echo&quot;<br><br>&quot;;
this shows $today in seconds from 1-1-1970;and this is good to add $oneday + $today.

echo&quot;date user votes is $row[ung_sur_date]<br>&quot;;
this shows 021104201011.
echo date( &quot;F d, Y&quot;, $row[ung_sur_date]);this shows an incorrect date, not november 4,2002. I can not find a mysql datatype that gives the number of second past 1-1-1970.

I want to use for my date math
$oneyearfuture = ($row[ung_sur_date] + ( $oneDay * 365));

echo&quot;one year in future from date user voted is $oneyearfuture<br>&quot;;
echo date( &quot;F d, Y&quot;, $oneyearfuture);
This shows an incorrect date becaude I am adding 021104201011 to the number of seconds passed 1-1-1970; which does not appear to be giving the correct date.

Do you know a datatype for a mysql table that shows number of seconds past 1-1-1970. Do you know of an easy fix to my problem of adding one year to $row[ung_sur_date]?
Thank You.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top