- getdate: documentation ( source)
<?php
class MyDateTime extends DateTime
{
public function setTimestamp( $timestamp )
{
$date = getdate( ( int ) $timestamp );
$this->setDate( $date['year'] , $date['mon'] , $date['mday'] );
$this->setTime( $date['hours'] , $date['minutes'] , $date['seconds'] );
}
public function getTimestamp()
{
return $this->format( 'U' );
}
}
$date = new MyDateTime();
$need_score = 248;
$timestamp = 1417763475;
$current_score = 0.7;
$date_now = new DateTime();
$date = new MyDateTime();
$date->setTimestamp($timestamp);
$interval_days = $date_now->diff($date)->days + 1;
print ($need_score - $current_score) * $interval_days;