Tech Musings

Wednesday, December 07, 2005

formatting date with PHP

<?php echo date ("n/j/Y G:i:s",strtotime($record['stamp']));  ?>


Used on teacher_exchange>details.php and eportfolio>portfolios.php

PHP date manual http://us3.php.net/date.

ADDED 4/18/06


On the VISIONS application, I wanted to return a message to the user that read something like this:

"...your file was submitted on Monday, January 13,2006 at 8:35 AM."

To accomplish this, I created 3 time variables ($time1, $time2, and $time3) using the following php date format parameters:

$time1 = date("l",strtotime($row_get_tid['stamp']));
$time2 = date("F j Y",strtotime($row_get_tid['stamp']));
$time3 = date("G:i A",strtotime($row_get_tid['stamp']));

and then inserted them into the body of my message appropriately.

"...your file was submitted on $time1, $time2 at $time3."

ADDED 7/17/07


To grab the current date using PHP for comparisons against a MySQL field formatted for DATE type 'YYYY-MM-DD':

<? $today = date("Y-m-d"); //get today's date ?>

I used this on the class_detail page when I updated it for cookies and cart action. Other potential MySQL date type properties might include:
DATETIME values in 'YYYY-MM-DD HH:MM:SS'

<? $today = date("Y-m-d H:i:s"); //get today's date ?>

0 Comments:

Post a Comment

<< Home