Date & Time Basics


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



Copy this code and paste it in your HTML
  1. // Set timezone
  2.  
  3. putenv('TZ=Australia/Adelaide');
  4.  
  5. // Date formatting
  6.  
  7. date("m.d.y"); // 03.10.01
  8. date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
  9. date("D M j G:i:s T Y"); // Sat Mar 10 17:16:08 MST 2001
  10. date("l F j, Y"); // Saturday March 10, 2001
  11. date("H:i:s"); // 17:16:17
  12.  
  13. date(DATE_RFC822); //RFC822 format date for RSS
  14.  
  15. // Change date from MySQL format
  16.  
  17. list($year,$month,$date) = explode('-',$mysql_date);
  18.  
  19. $new_date = date("D M j Y", mktime(0,0,0,$month,$date,$year));
  20.  
  21. // Get UNIX timestamp from date and time (hr-min-sec-month-day-year)
  22.  
  23. $stamp = mktime(0, 0, 0, 3, 0, 2000);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.