[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Date Display

Hello, I am pulling a start date and an end date from mysql and I would like for it to be mm/dd/yyyy. Right now it is showing like this:
2008-09-13- 2008-09-14
How would I be able to change this and where would I have to change the code. I pull both of these by calling <?PHP echo"$row_events['start']";?>-<?PHP echo""$row_events['end']"; ?>

Thank you for helping me to know where to change code for this.

Rob
0
pertrai1
Asked:
pertrai1
1 Solution
 
HuyBDCommented:
try this
<?PHP echo date('m-d-Y',$row_events['start']);?>-<?PHP echo date('m-d-Y',$row_events['end']); ?>

Open in new window

0
 
pertrai1Author Commented:
HuyBD, I tried this and it is showing the date as 12-31-1969? when that is not the date in the database. I have the fields start and end set in the database as date fields. Am I doing something wrong?

Rob
0
 
paulp75Commented:
try this


<?php list($startyear, $startmonth, $startday) = split( '-' , $row_events['start'] );
$eventstart_date = "$startmonth-$startday-$startyear";
echo $eventstart_date;
?>
 
<?php list($endyear, $endmonth, $endday) = split( '-' , $row_events['end'] );
$eventend_date = "$endmonth-$endday-$endyear";
echo $eventend_date;
?>

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now