Answer the question
In order to leave comments, you need to log in
How to calculate PHP Mysql date?
$date=date('Ydm');
$see = mysql_query("SELECT Age, Parse FROM $database.test ORDER BY Age DESC") or die(mysql_error());
$output = mysql_fetch_array($see)
$active=($output['Age'])+(($date)-($output['Parse']));
in general, I know what I did wrong. February began and the script incorrectly counts (42.1 for example).
Help, tell me how to properly organize and implement?
Age - VARCHAR with numbers, Parse - DATE (2017.01.08) Ymd
Answer the question
In order to leave comments, you need to log in
Good morning.
What are you going to calculate?
Here is an example of how to calculate the difference between dates:
$start = new DateTime(date('Y-m-d H:i', 1486362900), new DateTimeZone('Europe/Kiev'));
$end = new DateTime(date('Y-m-d H:i', 1486379400), new DateTimeZone('Europe/Kiev'));
$diff = $end->diff($start);
echo '<br>';
printf("The two dates have %d weeks, %s days, " .
"%d hours, %d minutes, and %d seconds " .
"elapsed between them.",
floor($diff->format('%a') / 7),
$diff->format('%a') % 7,
$diff->format('%h'),
$diff->format('%i'),
$diff->format('%s'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question