chevys Posted April 11, 2009 Share Posted April 11, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/ Share on other sites More sharing options...
.josh Posted April 11, 2009 Share Posted April 11, 2009 date Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807504 Share on other sites More sharing options...
chevys Posted April 11, 2009 Author Share Posted April 11, 2009 I tried several different combination i am new to all this PHP coding can you be alittle more specific please Thx Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807511 Share on other sites More sharing options...
.josh Posted April 11, 2009 Share Posted April 11, 2009 I think the manual is a lot more specific than I could ever be...did you scroll down and look at the examples? Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807516 Share on other sites More sharing options...
Mchl Posted April 11, 2009 Share Posted April 11, 2009 What did you try? If you show us we can tell you where you went wrong. Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807517 Share on other sites More sharing options...
chevys Posted April 11, 2009 Author Share Posted April 11, 2009 Dont laugh lol I tried date($PAYP[0]) I tried <?=date('F j, Y', $PAYP[0])?> I just cant figure it out I scrolled down that page you suggested and I cannot figure out which one will compare to what I am tring to do. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807525 Share on other sites More sharing options...
Mchl Posted April 11, 2009 Share Posted April 11, 2009 Did this show anything or nothing or an error? <?=date('F j, Y', $PAYP[0])?> Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807529 Share on other sites More sharing options...
chevys Posted April 11, 2009 Author Share Posted April 11, 2009 It came back as nothing when I tried that one. Am I missing a line above print telling it what to do? Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807530 Share on other sites More sharing options...
Mchl Posted April 11, 2009 Share Posted April 11, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807536 Share on other sites More sharing options...
chevys Posted April 11, 2009 Author Share Posted April 11, 2009 That worked thank you so much I have been trying this for the past 5hrs Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807538 Share on other sites More sharing options...
Mchl Posted April 11, 2009 Share Posted April 11, 2009 I would suggest that you have some fun with formatting the date, to see what are the different options available. It'll come in handy not once and not twice Quote Link to comment https://forums.phpfreaks.com/topic/153667-help-php-print-date-question/#findComment-807543 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.