| Author |
Message |
Richman New Member


Joined: Jul 01, 2004 Posts: 10
|
Posted:
Thu Jul 01, 2004 2:01 pm |
|
I wrote a PHP script that accesses a MySQL database to retrieve a number of schedule entries. I was wondering how I could format the date coming from the MySQL database to look more desirable, like a mm/dd/yy fasion. |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Jul 01, 2004 2:11 pm |
|
It depends on the incoming format, of course. See if these links help you |
|
|
|
 |
Richman New Member


Joined: Jul 01, 2004 Posts: 10
|
Posted:
Thu Jul 01, 2004 2:13 pm |
|
This is the format, I got it using the SQL function NOW().
2004-06-30 14:00:40 |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Jul 01, 2004 2:16 pm |
|
Yep, that would do it  |
|
|
|
 |
Richman New Member


Joined: Jul 01, 2004 Posts: 10
|
Posted:
Thu Jul 01, 2004 2:17 pm |
|
How would i get that into mm/dd/yy? I looked at the php.net manual and couldn't seem to find a way  |
|
|
|
 |
sixonetonoffun Spouse Contemplates Divorce

Joined: Jan 02, 2003 Posts: 2499
|
Posted:
Thu Jul 01, 2004 2:52 pm |
|
Here is a crude working example.
| Code: |
<?
$var="2004-06-30 14:00:40";
list($part1,$part2)=explode(" ", "$var");
list($nwyr,$nwmm,$nwdt)=explode("-", "$part1");
echo ("$nwmm-$nwdt-$nwyr");
?>
|
But in the long run it might be easier to store it in the format you want to retrieve it in since it would make it a little faster. |
|
|
|
 |
Richman New Member


Joined: Jul 01, 2004 Posts: 10
|
Posted:
Thu Jul 01, 2004 2:54 pm |
|
Thats one good point man... |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Jul 01, 2004 3:39 pm |
|
| Code: | <?
$now = '2004-06-30 14:00:40';
echo date('m-d-Y',strtotime($now));
?> |
|
|
|
|
 |
Richman New Member


Joined: Jul 01, 2004 Posts: 10
|
Posted:
Thu Jul 01, 2004 3:50 pm |
|
Thanks a lot! That should do it.  |
|
|
|
 |
|
|
|
|