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"seconds per day is $oneDay <br><br>";
$today = date( "U" );
echo"today is $today<br> ";
echo date( "F d, Y", $today );
echo"<br><br>";
this shows $today in seconds from 1-1-1970;and this is good to add $oneday + $today.
echo"date user votes is $row[ung_sur_date]<br>";
this shows 021104201011.
echo date( "F d, Y", $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"one year in future from date user voted is $oneyearfuture<br>";
echo date( "F d, Y", $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.
I am using mysql database and php.
My code:
$oneDay = 86400;
echo"seconds per day is $oneDay <br><br>";
$today = date( "U" );
echo"today is $today<br> ";
echo date( "F d, Y", $today );
echo"<br><br>";
this shows $today in seconds from 1-1-1970;and this is good to add $oneday + $today.
echo"date user votes is $row[ung_sur_date]<br>";
this shows 021104201011.
echo date( "F d, Y", $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"one year in future from date user voted is $oneyearfuture<br>";
echo date( "F d, Y", $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.