cade 0 Report post Posted July 17, 2005 (edited) aku ada satu script nak display date and time, aku nak papar kan dia sebiji macam putera.com buatcontoh:kalo user post a msg pada hari ini, date and time will display "today"...and also kalo user tu baru 2 jam lepas post entry, php akan display "2 hours ago"...mcm mana nak bina dlm php?if (date()==$row['masa']) echo "today";setakat ni jer aku dpt pikir kan dulu...sbb utk yg lain tu aku dah hadap berpuluh puluh kali kegagalan.... tq Edited July 17, 2005 by cade Quote Share this post Link to post Share on other sites
psychoX 6 Report post Posted July 18, 2005 rasanye kene simpan dalam database gak .. Quote Share this post Link to post Share on other sites
1kHz 0 Report post Posted July 18, 2005 cari beza masa sekarang dgn masa dari dlm DB..$dateFromDB = strtotime(row['masa']); $dateToday = mktime(); $diff = $dateToday - $dateFromDB;strotime akan tukarkan date dlm bentuk human-readable (eg. "2005-07-18") kepada UNIX timestamp.mktime akan ambil masa sekarang dlm bentuk UNIX timestampUNIX timestamp ni sebenarnya perwakilan masa dlm bentuk jumlah saat, jadi bila kita tolak dua masa diatas kita dapat saatnya.. maka $diff akan pegang beza dua masa tersebut dlm SAAT..kita dah dapat SAAT tu.. Now lets us see your logic on how to convert the SAAT to MINIT, JAM and so on..rujuk:http://php.net/manual/en/ref.datetime.phphttp://forums.ittutor.net/index.php?showtopic=27392http://www.michaelhorowitz.com/php/datediff.phphttp://www.google.com/search?q=php+date+difference Quote Share this post Link to post Share on other sites
cade 0 Report post Posted July 21, 2005 Note: Please keep in mind that these functions are dependent on the locale settings of your server. Make sure to take daylight saving time (use e.g. $date = strtotime('+7 days', $date) and not $date += 7*24*60*60) and leap years into consideration when working with these functions. apa maksud kat text yg aku highlight kan tuh?? p/s: aku punyer progress still slow due to takder pc kat umah....tak sempat pun nak baca link yg ader... Quote Share this post Link to post Share on other sites
1kHz 0 Report post Posted July 22, 2005 http://webexhibits.org/daylightsaving/http://www.google.com/search?q=daylight+saving+time Quote Share this post Link to post Share on other sites
cade 0 Report post Posted July 25, 2005 my progress.....function dateDiff($dateTimeBegin,$dateTimeEnd) {     $dateTimeBegin=strtotime($dateTimeBegin);     if($dateTimeBegin === -1) { /*apa maksud kat sini???*/      return("invalid begin time....");     }     $dateTimeEnd=strtotime($dateTimeEnd);     if($dateTimeEnd === -1)   {      return("invalid end time");     }     $dif=$dateTimeEnd - $dateTimeBegin;      switch($dif) {      case ($dif >= 1 ) && ($dif < 3600):       return(", " . floor($dif/60) . " minutes ago"); //1min = 60s      case ($dif >= 3600) && ($dif < 86400): // > 1hr and < 1day      return(", " . floor($dif/3600) ." hours ago" ); // 1hrs = 3600s      case ($dif > 86400) && ($dif <= 172800):      return(", yesterday");      default:        return(date("l dS of F Y h:i:s A",$dateTimeBegin));     } } aku copy dari link yg ader kat ats nih...tapi slightly modified...Tapi aku still ader beberapa kemuskilan utk code kat atas nih....dkt bahagian if condition. Apabila dia check dateTime === -1, apa maksud dia sebenarnya dia nih...??Kalo dlm PHP, kiter guner text area punyer kontrol sbg input dlm db kat mySQL, mcmana nak display exactly mcm user entered...contohnya, kite enter some text then kita press enter key, utk write new line & enter text kat situ.... Quote Share this post Link to post Share on other sites
1kHz 0 Report post Posted July 26, 2005 Example: $a === $bName: IdenticalResult: TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)Oleh sebab data dlm PHP ialah "loosely typed", maka ada operator ni utk banding nilai 2 variable sama termasuk jenis datanya..Gunakan nl2br() utk tukar linefeeds (\n) kpd tag <br> ..http://my2.php.net/nl2br Quote Share this post Link to post Share on other sites
cade 0 Report post Posted July 26, 2005 (edited) apa maksud -1 disitu?Adakah mail() function dlm php depending on server apa yg kiter guna? thanks Edited July 26, 2005 by cade Quote Share this post Link to post Share on other sites
1kHz 0 Report post Posted July 26, 2005 Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1 on failure.Tengok strtotime, kalau tak berjaya dia return -1 .. beware tho', there'll be some glitch if ur using this code in PHP 5.1.0 and above..Tengok, aku search PHP Manual.. kalau ko sendiri cari kat PHP Manual tentu boleh dpt jawapan dgn lebih cepat.. Quote Share this post Link to post Share on other sites
1kHz 0 Report post Posted July 26, 2005 mail() function kalau tak silap depends on the settings kat php.ini file..cuba check, aku tak pasti, tak pernah amik tahu.. Quote Share this post Link to post Share on other sites
cade 0 Report post Posted August 3, 2005 aku ader try buat guest book guner php, masalahnyer ialah camna nak halang data dari masuk ke dlm database apabila user baru saja click kat submit button utk post entry and then dia pergi click plak dkt Refresh button kat browser....Aku guna form method = get Quote Share this post Link to post Share on other sites