johanes Posted April 24, 2004 Report Share Posted April 24, 2004 Kā fiksēt pievienoto datumu ?????? Link to comment Share on other sites More sharing options...
Venom Posted April 24, 2004 Report Share Posted April 24, 2004 ja saglabāji failā, tad faila izveidošanas datumu var nolasīt ar filemtime() ķipa raksts izveidots date('d m H:i',filemtime($raksts)); ja glabā iekš db (MySQL), tad uztaisi papildus lauku, vai nu piem. TIMESTAMP tipa un tajā dzen iekšā NOW() funkcijas vērtību, vai CHAR(11) lauku, kurā glabā iekšā php funkcijas mktime() [gmmktime()] atgriesto vērtību. Link to comment Share on other sites More sharing options...
johanes Posted April 24, 2004 Author Report Share Posted April 24, 2004 Paldies Venon :) :) :) :) :) Link to comment Share on other sites More sharing options...
johanes Posted April 24, 2004 Author Report Share Posted April 24, 2004 (edited) Tik tālu man sanāk, nosakot faila papildināšanas laika, bet kā to izdarīt konkreti karam pievienojumam??????????? Un kā likt lai šķirotu ierakstus no jaunākā uz vecēko, jo tagad šķirošana notiek no pēdējā uz pirmo. Te ir arī pats skripts: <?header("Content-type:text/vnd.wap.wml;charset=utf-8"); print "<?xml version=\"1.0\"?>\n"; print "<wml>\n"; print "<card title=\"Ieraksti\">\n"; $shodien=date("d. m.y., H:i"); echo "$shodien\n"; echo "<p>----------------</p>\n"; $xfile = "guest.txt"; if (file_exists($xfile)) { echo "papildinats: " . date ("d,m, Y H:i:s.", filectime($xfile)); } $xfile = @file("guest.txt"); for ($i=count($xfile)-10;$i<count($xfile);$i++) { $udata = explode("::",$xfile[$i]); print "<p>$udata[0]<br/><b>$udata[1]</b><br/>$udata[2]<br/><small>$udata[3]</small></p><br/><br/>"; } ?> Edited April 24, 2004 by johanes Link to comment Share on other sites More sharing options...
bubu Posted April 24, 2004 Report Share Posted April 24, 2004 katram ierakstam datumu+laiku glabaat neesi iedomaajies? un kad nolasi failu, tad sakaarto peec shii laika, un buus tev shkjiroshana! Link to comment Share on other sites More sharing options...
johanes Posted April 25, 2004 Author Report Share Posted April 25, 2004 nu es tā izdarīj, bet vinš rāda Unix sistēm,as sākuma laiku - 1970g......, nevis reālo saglabāto. vot tā :( Link to comment Share on other sites More sharing options...
Aleksejs Posted April 25, 2004 Report Share Posted April 25, 2004 (edited) vinš rāda Unix sistēm,as sākuma laiku - 1970g......, nevis reālo saglabāto. Un kādi secinājumi tev ir no tā? Ja viņš tev nesaglabā failā pareizo laiku, pārbaudi, vai izmanto pareizo datuma funkciju. Ja no pareizi saglabāta laika viņš tev uztaisa nepareizu laiku pie PHP izvades klientam, tad apskaties, vai pareizi uztaisīta datumu konvertēšana. Edited April 25, 2004 by Aleksejs Link to comment Share on other sites More sharing options...
johanes Posted April 25, 2004 Author Report Share Posted April 25, 2004 jā tieši tā,ar laikum beidzot tiku galā. POaldies viesiem par palīdzību. Tagad nekādīgi nevaru iebraukt kā šķirot pēc laika....... Link to comment Share on other sites More sharing options...
Aleksejs Posted April 25, 2004 Report Share Posted April 25, 2004 (edited) Par šķirošanu: Returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer containing the number of seconds between the Unix Epoch (January 1 1970) and the time specified Edited April 25, 2004 by Aleksejs Link to comment Share on other sites More sharing options...
johanes Posted April 25, 2004 Author Report Share Posted April 25, 2004 mktime, jau sak skaiti laiku no kāda noteikta punkta. Man vajag sašķirot ierakstus txt failāp pēc datuma. ES prātā zinu kā tas būtu jādara, bet praktiski nevaru, nezinu visas funkcijas :(. Kaut kas nav ar sort funkc. Tass ir add.php: <? $lastmod = date("d M @ H:i"); $text = "$lastmod::$name::$mail::$mess"; $text=strip_tags($text); $file=file("guest.txt"); $counter=count($file); if ($counter == "1000") { $fp = @fopen("guest.txt","w+"); @fclose($fp); } $fp=@fopen("guest.txt","a"); fputs($fp,"$text \r\n"); @fclose($fp); header("Content-type:text/vnd.wap.wml;charset=utf-8"); print "<?xml version=\"1.0\"?> <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"> <wml> <card id=\"tes\" title=\"Ihtis wap\"> <p>Tava zinja tika veiksmiigi pievienota. Paldies</p> <br /> <do type=\"accept\" label=\"OK\"> <go href=\"guest.php\" method=\"post\"> </go> </do> </card> </wml>"; ?> Un guest.php: <? header("Content-type:text/vnd.wap.wml;charset=utf-8"); print "<?xml version=\"1.0\"?>\n"; print "<wml>\n"; print "<card title=\"Ieraksti\">\n"; $xfile = "guest.txt"; if (file_exists($xfile)) { echo "papildinats: " . date ("d,m, Y H:i:s.", filectime($xfile)); } $xfile = @file("guest.txt"); for ($i=count($xfile)-15;$i<count($xfile);$i++) { $udata = explode("::",$xfile[$i]); print "<p>=$udata[0]=<br/><b>$udata[1]</b><br/>$udata[2]<br/><small>$udata[3]</small></p><br/><center>--------------------</center><br/>"; } echo "<a title=\"pievienot\" href=\"guest.wml\">Pievienot vel</a><br/>\n"; echo "<a title=\"Enter\" href=\"http://ihtis.times.lv/wap\">[ uz sakumu ]</a><br/>\n"; echo "<p><center>><> ><> ><> ><> ><></center></p>\n"; echo "<p><center> © I h t i s</center></p>\n"; print "</card></wml>\n"; ?> Kaa vot šito daļiu šķirot $xfile = @file("guest.txt"); for ($i=count($xfile)-15;$i<count($xfile);$i++) { $udata = explode("::",$xfile[$i]); print "<p>=$udata[0]=<br/><b>$udata[1]</b><br/>$udata[2]<br/><small>$udata[3]</small></p><br/><center>--------------------</center><br/>"; Link to comment Share on other sites More sharing options...
johanes Posted April 25, 2004 Author Report Share Posted April 25, 2004 Hehe, beidzot atradu kļūdu for ($i=count($xfile)-15;$i<count($xfile);$i++) { nomeiniiju ar $cnt = count($xfile); for ( $i=$cnt-1; $i>=0; $i-- ) { Link to comment Share on other sites More sharing options...
Recommended Posts