PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Richman
New Member
New Member


Joined: Jul 01, 2004
Posts: 10

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

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: 16987
Location: Kansas

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

It depends on the incoming format, of course. See if these links help you
Only registered users can see links on this board!
Get registered or login to the forums!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Richman
New Member
New Member


Joined: Jul 01, 2004
Posts: 10

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

This is the format, I got it using the SQL function NOW().
2004-06-30 14:00:40
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

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

Yep, that would do it Smile
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Richman
New Member
New Member


Joined: Jul 01, 2004
Posts: 10

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

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
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

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

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.
View user's profile Send private message
Richman
New Member
New Member


Joined: Jul 01, 2004
Posts: 10

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

Thats one good point man...
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

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

Code:
<?
$now = '2004-06-30 14:00:40';
echo date('m-d-Y',strtotime($now));
?>
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Richman
New Member
New Member


Joined: Jul 01, 2004
Posts: 10

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

Thanks a lot! That should do it. RavensScripts
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum