user3404390
user3404390

Reputation: 97

Formatting how a time and date display from a variable

My Variables are in my sql table stored as a date and time respectively.

for the date, when i display the variable it displays as 2014-06-09

<?php
echo $info['seasonbegin'];
?>

when i try and format it, no matter which variable i declare (beginning or end) it displays as Wednesday December 31st

<?php
echo date("l F jS", $info['seasonbegin']);
?>

I don't understand what I am doing wrong. For a time I am trying to do with similar code, it does the same thing, no matter the value of the variable it displays 6pm...

Thanks for any help

Upvotes: 0

Views: 46

Answers (1)

Mark Miller
Mark Miller

Reputation: 7447

The second argument for date() is a timestamp, so you need to convert your original date to a timestamp. You can do this with strtotime():

echo date("l F jS", strtotime($info['seasonbegin']));

Upvotes: 1

Related Questions