C
C
chief2017-02-01 12:11:15
PHP
chief, 2017-02-01 12:11:15

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

1 answer(s)
D
Dmitry, 2017-02-01
@slo_nik

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'));

Here you have the dates both in Ymd and in numbers ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question