PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  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
rogue3
Regular
Regular


Joined: Jul 02, 2009
Posts: 63

PostPosted: Thu Sep 24, 2009 12:57 pm Reply with quote Back to top

I'm having a devil of a time getting the date to pull correctly from my database. All it does is pull December 31, 1969

I cannot get it to pull the date that is in the field in the database.

The field type is 'date' and name is 'date' and it is stored in this format: 2009-05-24

Here is the function code:

Code:
   while($myrow = $db->sql_fetchrow($result)) {
    $title = stripslashes(check_html($myrow["title"], "nohtml"));
    $id = intval($myrow['id']);
                $date = $myrow['date'];
   $fdate = date('F j, Y', $date);


What am I missing here?
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2456
Location: Pittsburgh, Pennsylvania

PostPosted: Thu Sep 24, 2009 1:10 pm Reply with quote Back to top

date() uses timestamps not formatted date strings.
Only registered users can see links on this board!
Get registered or login to the forums!
View user's profile Send private message
rogue3
Regular
Regular


Joined: Jul 02, 2009
Posts: 63

PostPosted: Thu Sep 24, 2009 1:54 pm Reply with quote Back to top

This is the same format that was used in my other sections. Why would it not be working here?
View user's profile Send private message
eldorado
Involved
Involved


Joined: Sep 10, 2008
Posts: 414
Location: France,Translator

PostPosted: Thu Sep 24, 2009 2:14 pm Reply with quote Back to top

rogue3 wrote:
December 31, 1969

if the date() has uncorresponding arguments it returns the 0 value wich corresponds to 1st January 1970 Smile (unix date)
I suggest you look at this
Only registered users can see links on this board!
Get registered or login to the forums!

or the php manual
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 MSN Messenger
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Thu Sep 24, 2009 5:53 pm Reply with quote Back to top

Let us not be mixing MySQL DATE formats with PHP. You may want to read this:
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
rogue3
Regular
Regular


Joined: Jul 02, 2009
Posts: 63

PostPosted: Thu Sep 24, 2009 5:56 pm Reply with quote Back to top

The dates that are in the fields in the database are all different. For some reason it does not pull the date from the field, but instead puts the same date for all of them.
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Thu Sep 24, 2009 5:59 pm Reply with quote Back to top

What do you get when you just echo out the $date field.

BTW, what the others were trying to say is that you cannot use the PHP date() function on anything other than a unix time stamp.
View user's profile Send private message Visit poster's website
rogue3
Regular
Regular


Joined: Jul 02, 2009
Posts: 63

PostPosted: Thu Sep 24, 2009 6:04 pm Reply with quote Back to top

OK, I SWEAR I tried this before, but now it is working. Good grief.

Here's the code that is now working:

Code:
         $date = $myrow['date'];
    $year = substr($date,0,4);
      $month = substr($date,5,2);
     $day = substr($date,8,2);
     $fdate = date("F jS Y",mktime (0,0,0,$month,$day,$year));
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Thu Sep 24, 2009 6:08 pm Reply with quote Back to top

Yes, what you posted works because it takes the "YYYY-MM-DD" format and "converts" it to a datetime stamp which then the date() function can format.
View user's profile Send private message Visit poster's website
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