Pentiums Posted February 4, 2008 Report Posted February 4, 2008 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
andrisp Posted February 4, 2008 Report Posted February 4, 2008 1) Izskatās pareizs. Tikai pārsauc savādāk. PHP jau ir tāda iebūvēta date() funkcija. 2) Izmanto tur, kur tev vajag. echo custom_date($timestamp);
Pentiums Posted February 4, 2008 Author Report Posted February 4, 2008 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?
andrisp Posted February 4, 2008 Report Posted February 4, 2008 Aizvietot labāk nemēģini. 99%, ka nočakarēsi visu sistēmu. ;)
Pentiums Posted February 4, 2008 Author Report Posted February 4, 2008 a nevar vinu tajaa funkcijaa iebazt ieksaa? kautkā..
andrisp Posted February 4, 2008 Report Posted February 4, 2008 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; }
Pentiums Posted February 4, 2008 Author Report Posted February 4, 2008 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
Pentiums Posted February 4, 2008 Author Report Posted February 4, 2008 bet ja es uztaisu to funkciju un nosaucu kautvai par sodiena() kā man vinu pievienot te? $res .= $locale['041'].showdate("longdate", $info['news_date']);
andrisp Posted February 4, 2008 Report Posted February 4, 2008 Iespējams, ka šādi: $res .= $locale['041'].sodiena($info['news_data']);
Pentiums Posted February 4, 2008 Author Report Posted February 4, 2008 un nevar kautkā saglabājot showdate funkciju?
andrisp Posted February 4, 2008 Report Posted February 4, 2008 Pentiums, tas ir kā saglabājot ? Tu taču viņu neizdzēs.
Pentiums Posted February 4, 2008 Author Report Posted February 4, 2008 uz db viņš saglabā savu timestampu.. šis te ir izvadot
andrisp Posted February 4, 2008 Report Posted February 4, 2008 Nesapratu, ko tu gribi man patiekt, bet uz DB nekas netiek mainīts. Un es labi saproti, ka tas ir paredzēts priekš izdrukāšanas tikai.
Recommended Posts