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
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Tue Dec 12, 2006 8:28 pm Reply with quote

This is stored in the db as varchar and is ten digits. I assume this is a timestamp and I'm trying to extract it and format for display.

The only thing I've gotten to display is Dec 30, 1969.

I can't figure this out and I've been researching it for an hour.

Code:
$sql = $db->sql_query("SELECT game_id, winner, loser, date, winnerscores, loserscores FROM " . $prefix . "_tc_playedgames tcp 

   JOIN " . $prefix . "_tc_ladders tcl
   WHERE tcp.ladder_id = tcl.sid
   AND tcl.active = '1'");
   while ( $row = $db->sql_fetchrow($sql) ) {

         $game_id = $row['game_id'];
         $winner = $row['winner'];
         $loser = $row['loser'];
         $date = $row['date'];
         list($Year,$Month,$Day) = split('-',$date);
         $matchdate = date("M j, Y",mktime(12,0,0,$Month,$Day,$Year));
         $winnerscores = $row['winnerscores'];
         $loserscores = $row['loserscores'];


Ideally I need to display something like Dec 11, 2006 9:28AM
 
View user's profile Send private message Visit poster's website ICQ Number
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Tue Dec 12, 2006 9:14 pm Reply with quote

May want to try the strtotime function to convert the date into a Unix timestamp [ Only registered users can see links on this board! Get registered or login! ]

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
Donovan







PostPosted: Tue Dec 12, 2006 10:03 pm Reply with quote

Nope.

Now it says -1 for all the dates.


Code:
$sql = $db->sql_query("SELECT game_id, winner, loser, date, winnerscores, loserscores FROM " . $prefix . "_tc_playedgames tcp 

   JOIN " . $prefix . "_tc_ladders tcl
   WHERE tcp.ladder_id = tcl.sid
   AND tcl.active = '1'");
   while ( $row = $db->sql_fetchrow($sql) ) {

         $game_id = $row['game_id'];
         $winner = $row['winner'];
         $loser = $row['loser'];
         $date = $row['date'];   
         $matchdate = strtotime('F j, Y, g:i a',$date);
         $winnerscores = $row['winnerscores'];
         $loserscores = $row['loserscores'];      
                  
      
    echo"<tr>"   
   . "<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">$matchdate</td>"
 
djmaze
Subject Matter Expert



Joined: May 15, 2004
Posts: 727
Location: http://tinyurl.com/5z8dmv

PostPosted: Wed Dec 13, 2006 7:41 am Reply with quote

what does the field 'date' contain?
Without knowing what it has you're screwed

_________________
$ mount /dev/spoon /eat/fun auto,overclock 0 1
ERROR: there is no spoon [ Only registered users can see links on this board! Get registered or login! ] 
View user's profile Send private message Visit poster's website
Donovan







PostPosted: Wed Dec 13, 2006 8:03 am Reply with quote

varchar (40)


The field has this as a value

1165318740
 
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Wed Dec 13, 2006 8:38 am Reply with quote

If that is a unix timestamp, then its about 2006'ish. Does that sound right?

Use the date() function on it and see. [ Only registered users can see links on this board! Get registered or login! ]

$prettyDate = date('F j, Y, g:i a', $date);

_________________
GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module 
View user's profile Send private message
Donovan







PostPosted: Wed Dec 13, 2006 2:05 pm Reply with quote

That worked. Thanks
 
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 ©