Posted By

tylerhall on 10/11/06


Tagged

time date format timestamp


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

basicmagic
vali29
hudge
willcodeforfood
benrasmusen
pixelhandler
blackf0rk
loric
dantreacy
joethermal


Format Date


 / Published in: PHP
 

This is just a wrapper for PHP's date() function which allows you to pass a timestamp or a string to be formatted as specified. By default it returns the current date formatted as a MySQL datetime value.

  1. function dater($format = "", $date = "")
  2. {
  3. if($format == "") $format = "Y-m-d H:i:s";
  4. if($date == "") $date = time();
  5.  
  6. $converted = strtotime($date);
  7. if($converted === false)
  8. return date($format, $date);
  9. else
  10. return date($format, $converted);
  11. }

Report this snippet  

You need to login to post a comment.