Jump to content


Photo

Get date from mysql date coloum formated correct


  • Please log in to reply
4 replies to this topic

#1 avo

avo
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • Locationstaffordshire uk

Posted 02 July 2006 - 04:51 PM

Hi all

Nice new site!! I LIKE IT !!. ;D

Can anyone please help me out here i have a date coloum in mysql db once ive entered a date in the sql what would be the best way to get this date out and reformated to a uk date DD-MM-YYYY

i was trying this but for some reson it misses the year out when i echo

<input name="txt_con_expiry" type="text" id="txt_con_expiry" value="<? $tempdate=explode("-", $txt_con_expiry);
echo $tempdate[3];
echo $tempdate[2];
echo $tempdate[1];?>
" />


$txt_con_expiry is a variable set when it is SELECTED FROM MY DB
Any ideas please
Im loving it ........

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 02 July 2006 - 04:57 PM

In what way is it stored in db? Timestamp? Other format?

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 avo

avo
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • Locationstaffordshire uk

Posted 02 July 2006 - 05:04 PM

Hi

When its entered into the db yes im using timestamp formated when it goes in
as

YYYY-MM-DD
Im loving it ........

#4 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 02 July 2006 - 05:15 PM

//$db_date is the date in db
//$format is after we change the order. 
$arr=explode("-",$db_date);
$format=$arr[2]."-".$arr[1]."-".$arr[0];
 

This is what you wanted??

Orio.
Think you're smarty?

(Gone until 20 to November)

#5 avo

avo
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • Locationstaffordshire uk

Posted 02 July 2006 - 05:20 PM

HI Thanks


How did i forget about counts starting at zero not 1

KICKING MYSELF  !!!!


Thanks Help Greatly Appriciated
Im loving it ........




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users