Wednesday, February 8, 2012

Compare date with PHP

Selalu nye kan... kalau nak wat coding PHP untuk compare tarikh mesti pening... kena wat if else utk day, month, year.... Sampai pening2... bile search on pakcik google... at last i found this simple of code yg wat my life happy sgt2... ;D

// your first date coming from a mysql database (date fields)
$dateA = '2008-03-01 13:34';

// your second date coming from a mysql database (date fields)
$dateB
= '2007-04-14 15:23';

if
(strtotime($dateA) > strtotime($dateB)){
// bla bla

}

nak tau lebih details tentang comparison tarikh ni... try browse from this source
http://www.thetricky.net/php/Compare%20dates%20with%20PHP

Wish you enjoy it... ;D

2 comments:

  1. Cik Erni.. bole ajar photoshop kt sni tak. :)

    ReplyDelete
  2. photoshop? good idea gak tu.. boleh2.. nanti ade tutorial best eni share kan eyy.. ;D

    ReplyDelete