timestamp phpmyadmin in dreamweaver
working phpmyadmin, i've got table called news
with field called time
and type timestamp (standard value: current_timestamp; on update current_timestamp)
now using dreamweaver, insert following code show time field on page:
<?php echo $row_news ['time']; ?>
which returns 2009-04-20 14:54:02 example, though in format (0000-00-00 00:00:00)
since i'm european, way of time notation 'weird' least. prefer see written 20-04-2009 14u54
it's 'annoying' me because can't find way around myself , i've googled *** off on matter. suggestions?
mysql stores dates in iso recommended format, yyyy-mm-dd hh:mm:ss. avoids annoyances of trying work out whether date entered american, european, or east asian, of whom use different ways display date , time.
so, how display date , time in own preferred format? simple. use mysql date_format() function, , assign result alias using keyword. details of date_format() , other date/time functions in mysql documentation @ http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html.
to display date in preferred format, use following sql:
select column1, column2, date_format(time, '%d-%m-%y %ku%s') formatted_time mytable
you can retrieve part of recordset $row_new['formatted_time'].
the formatting character specifiers listed in mysql page referred earlier. in example, column1, column2 represent other columns (fields want retrieve database in sql query.
More discussions in Develop server-side applications in Dreamweaver
adobe
Comments
Post a Comment