Welcome Guest, Not a member yet? Register   Sign In
Need help printing formatted mysql datetime field
#1

[eluser]intoitdaily[/eluser]
Hey guys, new to CodeIgniter, (this is my first post) but I imagine I'll be using this for as long as I develop websites. I LOVE IT! Anyway, as the title indicates, I can't seem to print a formatted mysql datetime field.
Code:
<?php print $row->date; ?>

Output:
2009-04-26 20:13:33
but when I try something like:
Code:
<?php print date_format($row->date, 'g:i a - M jS, Y'); ?>

I also tried
Code:
<?php print date('g:i a - M jS, Y', $row->date); ?>

Either way. CodeIgniter gives me the error
Code:
A PHP Error was encountered

Severity: Warning

Message: date_format() expects parameter 1 to be DateTime, string given

Filename: views/blog_id_view.php

Line Number: 19

Can I get some help or suggestions? If it would make things easier I can change the mysql table field to be a timestamp, but it doesn't make sense why I wouldn't be able to format it as is. Thanks in advanced!


Messages In This Thread
Need help printing formatted mysql datetime field - by El Forum - 04-27-2009, 10:59 PM
Need help printing formatted mysql datetime field - by El Forum - 04-27-2009, 11:03 PM
Need help printing formatted mysql datetime field - by El Forum - 04-27-2009, 11:21 PM
Need help printing formatted mysql datetime field - by El Forum - 04-28-2009, 01:55 AM
Need help printing formatted mysql datetime field - by El Forum - 04-28-2009, 02:24 AM
Need help printing formatted mysql datetime field - by El Forum - 04-28-2009, 04:15 AM
Need help printing formatted mysql datetime field - by El Forum - 05-01-2009, 09:59 AM
Need help printing formatted mysql datetime field - by El Forum - 05-02-2009, 06:36 AM
Need help printing formatted mysql datetime field - by El Forum - 05-02-2009, 06:46 AM
Need help printing formatted mysql datetime field - by El Forum - 05-03-2009, 10:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB