Jump to content


Photo

PHP date format


  • Please log in to reply
2 replies to this topic

#1 reazik

reazik
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 24 March 2006 - 08:50 PM

Hi all.

I'm new (no kidding; I'm posting in the newbie section!) :)

I'm adapting a job bulletin script for my company, and I'm trying to create a column that shows when the job listing was last updated. There was already a job_date column built into the MySQL code, so I used that in my page; however, it comes through as a string of numbers, and I have no idea how to fix it.

Here's the code blurb:

<table width="90%">
<tr valign="top" {ALTERNANCE}>
<td width="30" class="style1"><a href="details.php?id={JOB_ID}" class="style2">{JOB_NAME_TITLE}</a></td>
<td width="60" align="center" class="style1">{JOB_STATE}</td>
<td width="300" class="style1">{JOB_SUMMARY}</td>
[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]<td width="110" colspan="2" class="style1">{JOB_DATE}[!--colorc--][/span][!--/colorc--]
</td>
</tr>
</table>

and [a href=\"http://www.psninc.net/forms/JobBulletin/list.php\" target=\"_blank\"]Here's[/a] the result. Is there anything I can do to convert it? Is this even a PHP function?

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 24 March 2006 - 09:10 PM

You can format the the date in the query using MySQL's DATE_FORMAT() function or you can do it in PHP using the date() function. eg

$formatted_date = date('j M Y', $dbdate);

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 reazik

reazik
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 24 March 2006 - 09:21 PM

[!--quoteo(post=358055:date=Mar 24 2006, 04:10 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 24 2006, 04:10 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You can format the the date in the query using MySQL's DATE_FORMAT() function or you can do it in PHP using the date() function. eg

$formatted_date = date('j M Y', $dbdate);
[/quote]

Where do I need to put this code? I've tried various ways, but I keep getting text instead of reformatting the date. I really appreciate your help.

I had already tried to do it through MySQL, but it just blanked out the dates and gave me 0000-00-00.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users