Jump to content
php.lv forumi

Šodien / Vakar | timestampi


Pentiums

Recommended Posts

function date($timestamp, $offset = 0, $dotoday = true, $date_format = "M d, Y -", $time_format = "h:i A")
{
 $time_offset  = (-1 * $offset * 60 * 60);
 $date		 = gmdate($date_format." ".$time_format, $timestamp - $time_offset);

 // Today/Yesterday.
 if ($dotoday)
 {
$today	  = gmdate($date_format, time() - $time_offset);
$yesterday  = gmdate($date_format, time() - 86400 - $time_offset);

$date	   = str_replace($today, "Today,", $date);
$date	   = str_replace($yesterday, "Yesterday,", $date);
 }

 return $date;
}

 

šis te esot universālais timestampu parveidotajs.. ja ir sodiena tad rada today ja vakardiena tad yesterday

 

tas kods ir pareizs? un kur man vins jaliek? ja es lietoju php-fusion CMS

Link to comment
Share on other sites

un ko man darīt ja man jau eksistē arī tāda funkcija

function showdate($format, $val) {
global $settings;
if ($format == "shortdate" || $format == "longdate" || $format == "forumdate") {
	return strftime($settings[$format], $val+($settings['timeoffset']*3600));
} else {
	return strftime($format, $val+($settings['timeoffset']*3600));
}
}

 

un man arī to iepriekšējo tad vajag uz showdate();

kā tad lai šajā funkcijā iemontē klāt vēl to iepriekšējo?

Link to comment
Share on other sites

Eh.. nu var mēģināt. Pamēģini aizvietot to showdate() ar šo:

 

function showdate($date_format, $timestamp, $offset = 0, $dotoday = true, $time_format = "h:i A") {
 $time_offset  = (-1 * $offset * 60 * 60);
 $date		 = gmdate($date_format." ".$time_format, $timestamp - $time_offset);

 // Today/Yesterday.
 if ($dotoday)
 {
$today	  = gmdate($date_format, time() - $time_offset);
$yesterday  = gmdate($date_format, time() - 86400 - $time_offset);

$date	   = str_replace($today, "Today,", $date);
$date	   = str_replace($yesterday, "Yesterday,", $date);
 }

 return $date;
}

Link to comment
Share on other sites

daļu pārveidoja kā vajag otru daļu uztaisīja par pliku timestampu a taas abas funkcijas nevar apvienot kopaa? lai ir abu saturs vienaa

Link to comment
Share on other sites

bet ja es uztaisu to funkciju un nosaucu kautvai par sodiena()

 

kā man vinu pievienot te?

 

$res .= $locale['041'].showdate("longdate", $info['news_date']);

Link to comment
Share on other sites

×
×
  • Create New...