Jump to content

Changing the date format from epoch to human readable


toocreepy

Recommended Posts

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.