Posted By


razel on 02/06/08

Tagged


Statistics


Viewed 541 times
Favorited by 0 user(s)

create_timestamp


/ Published in: PHP
Save to your folder(s)

Forms a php timestamp out of an date string i.e. create_timestamp(24.12.2007);


Copy this code and paste it in your HTML
  1. function create_timestamp($date) { // Format : DD.MM.YYYY
  2. if (preg_match("/^([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})$/i",$date))
  3. {
  4. $expDate=explode(".",$date);
  5. if(strlen($expDate[0])=="1"){$expDate[0]="0".$expDate[0];}
  6. if(strlen($expDate[1])=="1"){$expDate[1]="0".$expDate[1];}
  7. return mktime(0,0,0,$expDate[1],$expDate[0],$expDate[2]);
  8. }
  9. else return false;
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.