toocreepy Posted January 5, 2011 Share Posted January 5, 2011 Hi, I have a date and time stored in a database field (publishdate) and I'm using php to fetch it and display it in an HTML table. Only problem is it shows up in epoch time. I can't get it to display in human readable time for some reason. Here's the code I'm using (it's automatically generated by some software) // View column for publishdate field $column = new TextViewColumn('publishdate', 'Publishdate', $this->dataset); $column->SetOrderable(true); Many thanks in advance. Tony Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 5, 2011 Share Posted January 5, 2011 $date = date("m/d/Y", timestamp); where timestamp is the number recovered from your db Quote Link to comment Share on other sites More sharing options...
toocreepy Posted January 5, 2011 Author Share Posted January 5, 2011 Thanks. I'm really new at this. I added that, but not sure where to put it. Here is what's coming back.... Publish Date: 1147845600 Should be.... Publish Date: Wednesday, May 17, 2006 12:00:00 AM Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 5, 2011 Share Posted January 5, 2011 ok show us your actual code Quote Link to comment Share on other sites More sharing options...
toocreepy Posted January 5, 2011 Author Share Posted January 5, 2011 It's attached. Line 536 is where it's putting in the publishdate Many thanks!! [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 5, 2011 Share Posted January 5, 2011 Line 536 is not outputting anything it is calling a class. And the class is not included in that file. Which is amazing since that file has nearly 2,000 lines of code (should really look into modularizing your code). Anyway, it is impossible for us to know what that class is really doing. I was going to suggest modifying the date before you call the class to output the publish date, but the date is apparently in the object $this->dataset. However, you didn't state how the value is stored in that object and I'm not going to reverse engineer all of that code to figure it out. It could be simply $this->dataset['publishdate'] or $this->dataset['PublishDate'] (I see both used) or it could be in a subarray of that object. I can tell from the values passed to the class $column = new TextViewColumn('publishdate', 'Publishdate', $this->dataset); That the class must have some specific code for each value since the output actually has "Publish Date". So, I would edit the class so the code to output the publish date will expect a timestamp but will output the date in the format you want. Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 5, 2011 Share Posted January 5, 2011 Your code is beyond my capabilities - what did you use to create it and/or where it you acquire it? Quote Link to comment Share on other sites More sharing options...
toocreepy Posted January 5, 2011 Author Share Posted January 5, 2011 www.sqlmaestro.com/products/mysql/phpgenerator/ Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 5, 2011 Share Posted January 5, 2011 Hmmm or you bought it. If it were me, I would contact their support team and ask them EXACTLY what and where you should make the changes. Technical support SQL Maestro Group provides all registered users with responsible support. Our Support Team guarantees to consider each question from the software users carefully and to supply a response within the nearest 24 hours. As a rule, we try to respond to all the incoming messages, but our registered users are the first to receive a quick response. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 5, 2011 Share Posted January 5, 2011 I really hate trying to code in the blind, but I will make some assumptions and give you a possible solution: Add the second line below where specified // View column for publishdate field $this->dataset['publishdate'] = date('l, F j, Y H:i:s A', $this->dataset['publishdate']); $column = new TextViewColumn('publishdate', 'Publishdate', $this->dataset); $column->SetOrderable(true); If that doesn't work do a data dump of $this->dataset so we can determine what really needs to be modified. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.