Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Richman
New Member
New Member



Joined: Jul 01, 2004
Posts: 10

PostPosted: Thu Jul 01, 2004 2:01 pm Reply with quote

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.
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Thu Jul 01, 2004 2:11 pm Reply with quote

It depends on the incoming format, of course. See if these links help you http://www.google.com/search?hl=en&ie=UTF-8&q=php+formatting+date+time
 
View user's profile Send private message
Richman







PostPosted: Thu Jul 01, 2004 2:13 pm Reply with quote

This is the format, I got it using the SQL function NOW().
2004-06-30 14:00:40
 
Raven







PostPosted: Thu Jul 01, 2004 2:16 pm Reply with quote

Yep, that would do it Smile
 
Richman







PostPosted: Thu Jul 01, 2004 2:17 pm Reply with quote

How would i get that into mm/dd/yy? I looked at the php.net manual and couldn't seem to find a way Embarassed
 
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Thu Jul 01, 2004 2:52 pm Reply with quote

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.

_________________
[b][size=5]openSUSE 11.4-x86 | Linux 2.6.37.1-1.2desktop i686 | KDE: 4.6.41>=4.7 | XFCE 4.8 | AMD Athlon(tm) XP 3000+ | MSI K7N2 Delta-L | 3GB Black Diamond DDR
| GeForce 6200@433Mhz 512MB | Xorg 1.9.3 | NVIDIA 270.30[/size:2b8 
View user's profile Send private message
Richman







PostPosted: Thu Jul 01, 2004 2:54 pm Reply with quote

Thats one good point man...
 
Raven







PostPosted: Thu Jul 01, 2004 3:39 pm Reply with quote

Code:
<?

$now = '2004-06-30 14:00:40';
echo date('m-d-Y',strtotime($now));
?>
 
Richman







PostPosted: Thu Jul 01, 2004 3:50 pm Reply with quote

Thanks a lot! That should do it. RavensScripts
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©