Zamiana daty typu dd-mm-YYYY na np. "dzisiaj" gdy data jest taka sama jak dzisiejsza.
datę wyświetlam czymś takim
<div>
<span class="date_added">
<span>
<?php echo date::my($a->annoucement_date_added, 'announcement') ?> </span>
</span>
</div>
Znalazłem jeszcze w kontrolerze daty coś odpowiedzialnego za format:
class Date extends I18n_Date
{
public static function my
($value, $type = NULL) {
$format = NULL;
if ($type !== NULL)
{
$format = Kohana::$config->load('date.' . $type);
}
if ($format === NULL)
{
$format = 'd-m-Y';
}
{
$date = date($format, $value); }
else
{
$date = date($format, $date); }
return $date;
}
/**
* Returns time difference between two timestamps, in human readable format.
* If the second timestamp is not given, the current time will be used.
* Also consider using [Date::fuzzy_span] when displaying a span.
*
* $span = Date::span(60, 182, 'minutes,seconds'); // array('minutes' => 2, 'seconds' => 2)
* $span = Date::span(60, 182, 'minutes'); // 2
*
* @param integer $remote timestamp to find the span of
* @param integer $local timestamp to use as the baseline
* @param string $output formatting string
* @return string when only a single output is requested
* @return array associative list of all outputs requested
*/
public static function span
($remote, $local = NULL, $output = 'years,months,weeks,days,hours,minutes,seconds') {
// Normalize output
if ( ! $output)
{
// Invalid output
return FALSE;
}
// Array with the output formats
// Convert the list of outputs to an associative array
//Fix bug: Only variables should be passed by reference
// Make the output values into keys
if ($local === NULL)
{
// Calculate the span from the current time
}
// Calculate timespan (seconds)
$timespan = abs($remote - $local);
if (isset($output['years'])) {
$timespan -= Date::YEAR * ($output['years'] = (int
) floor($timespan / Date::YEAR)); }
if (isset($output['months'])) {
$timespan -= Date::MONTH * ($output['months'] = (int
) floor($timespan / Date::MONTH)); }
if (isset($output['weeks'])) {
$timespan -= Date::WEEK * ($output['weeks'] = (int
) floor($timespan / Date::WEEK)); }
if (isset($output['days'])) {
$timespan -= Date::DAY * ($output['days'] = (int
) floor($timespan / Date::DAY)); }
if (isset($output['hours'])) {
$timespan -= Date::HOUR * ($output['hours'] = (int
) floor($timespan / Date::HOUR)); }
if (isset($output['minutes'])) {
$timespan -= Date::MINUTE * ($output['minutes'] = (int
) floor($timespan / Date::MINUTE)); }
// Seconds ago, 1
if (isset($output['seconds'])) {
$output['seconds'] = $timespan;
}
if (count($output) === 1) {
// Only a single output was requested, return it
}
// Return array
return $output;
}
}
Starałem się użyć jakiejś funkcji ale za każdym razem błąd - nie mam już sił proszę o pomoc.