Pentiums Posted February 4, 2008 Report Share 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 Link to comment Share on other sites More sharing options...
andrisp Posted February 4, 2008 Report Share 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); Link to comment Share on other sites More sharing options...
Pentiums Posted February 4, 2008 Author Report Share 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? Link to comment Share on other sites More sharing options...
andrisp Posted February 4, 2008 Report Share Posted February 4, 2008 Aizvietot labāk nemēģini. 99%, ka nočakarēsi visu sistēmu. ;) Link to comment Share on other sites More sharing options...
Pentiums Posted February 4, 2008 Author Report Share Posted February 4, 2008 a nevar vinu tajaa funkcijaa iebazt ieksaa? kautkā.. Link to comment Share on other sites More sharing options...
andrisp Posted February 4, 2008 Report Share 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; } Link to comment Share on other sites More sharing options...
Pentiums Posted February 4, 2008 Author Report Share 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 Link to comment Share on other sites More sharing options...
andrisp Posted February 4, 2008 Report Share Posted February 4, 2008 Nē. Link to comment Share on other sites More sharing options...
Pentiums Posted February 4, 2008 Author Report Share 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']); Link to comment Share on other sites More sharing options...
andrisp Posted February 4, 2008 Report Share Posted February 4, 2008 Iespējams, ka šādi: $res .= $locale['041'].sodiena($info['news_data']); Link to comment Share on other sites More sharing options...
Pentiums Posted February 4, 2008 Author Report Share Posted February 4, 2008 un nevar kautkā saglabājot showdate funkciju? Link to comment Share on other sites More sharing options...
marcis Posted February 4, 2008 Report Share Posted February 4, 2008 Grūti tev uzlikt unikālu nosaukumu?? Link to comment Share on other sites More sharing options...
andrisp Posted February 4, 2008 Report Share Posted February 4, 2008 Pentiums, tas ir kā saglabājot ? Tu taču viņu neizdzēs. Link to comment Share on other sites More sharing options...
Pentiums Posted February 4, 2008 Author Report Share Posted February 4, 2008 uz db viņš saglabā savu timestampu.. šis te ir izvadot Link to comment Share on other sites More sharing options...
andrisp Posted February 4, 2008 Report Share 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. Link to comment Share on other sites More sharing options...
Recommended Posts