Jump to content

HELP PHP "PRINT" DATE QUESTION


chevys

Recommended Posts

I have a question regarding a Print Fuction I have posted the code below.

 

print("<tr>"); 

                print("<td height=\"20\"class=\"row1\"align=\"left\">$PAYP[0]</td>");

  print("<td height=\"20\"class=\"row1\"align=\"left\">$user[1]</td>");

print("<td height=\"20\"class=\"row1\"align=\"left\">$credits</td>");

print("<td height=\"20\"class=\"row1\"align=\"left\">$PAYP[2]</td>");

  print("</tr>");

 

The line that consist of $PAYP[0] returns the date when the user made a purchase but it is in this format - 1239333028 - I need it to display in the format for example 4/11/09 can anyone help?

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/
Share on other sites

Ok, look at this line

 

print("<td height=\"20\"class=\"row1\"align=\"left\">$PAYP[0]</td>");

as you probably know it prints the content of $PAYP[0] which is a timestamp

 

if you want to print a formatted date instead, you need to convert this timestamp first

 

for example:

 

$dateFormatted = date("Y/m/d",$PAYP[0]);
print("<td height=\"20\"class=\"row1\"align=\"left\">$dateFormatted</td>");

 

or you can do this in one step

 

print("<td height=\"20\"class=\"row1\"align=\"left\">".date("Y/m/d",$PAYP[0])."</td>");

notice, that I had to use . before and after date(). This dot tells PHP to join (the proper term is concatenate ... I still need a spellchecker for this) the strings on both side of it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.