user1794656
user1794656

Reputation:

code issue convert time in PHP

having issues getting code to work properly and am sure I'm just missing something.

Previously I was using the following code:

 echo "<td>" .date("d-M-Y H:i", strtotime($row['vertrekdatum2'])). "</td>";

And have recently redone my php page template so that I can just use the following format for codes:

<? echo "$row[vertrekdatum2]"?>

However, in my previous page I was formatting the date/time to be something more like: 01-Dec-2013 15:14 in the output.

I have been trying to figure out how I would do this with the above code. I have tried the following, but all give me an errors message:

 Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in   
 /home/...../public_html/vluchtgegevens/test.php on line 108

I've tried <? echo "date("d-M-Y H:i", strtotime($row[vertrekdatum2]))"?> <? echo "date("d-M-Y H:i", strtotime($row[vertrekdatum2]));"?>

What am I missing?

Upvotes: 1

Views: 83

Answers (1)

Nambi
Nambi

Reputation: 12042

Use Single quotes ' not double quotes "" inside the date function

Do like this

    <?php echo date('d-M-Y H:i', strtotime($row[vertrekdatum2])); ?>  
    <?php echo date('d-M-Y H:i', strtotime($row[vertrekdatum2])); ?>

Upvotes: 1

Related Questions