Format UNIX Timestamp to Human Readable Time Format Using Custom Formatter

For UNIX timestamp, the set_col_edittype will not work due to the data format. A workaround is to use custom formatter javascript with a little bit "hack":

The sample code below, last_update is the the database table field in UNIX timestamp type. dateFormatter is the javascript function to convert UNIX timestamp to readable date time. Must surround the javascript function name with ### to be later escaped by phpGrid internal code.

// add your own code here....
$dg->set_col_property('last_update', array('formatter'=>'###dateFormatter###')); // must have ###
// more code here....

    function dateFormatter (cellValue, options, rowdata)
        if (cellValue==0){
            return 'N/A';
        var time = new Date();
        time.setTime (cellValue * 1000);
        var day = time.getDate();
        var month = time.getMonth()+1;
        var year = time.getFullYear();
        var hours = time.getMinutes();
        var minutes = time.getMinutes();

        var niceDate = year+'/'+month+'/'+day;
        return niceDate;

Datagrid Display

  1. Cannot display datagrid in IE8, but works in Firefox
  2. Display Icon/Image In a Virtual Column
  3. Change date display format
  4. Collapse Datagrid on Initial Display
  5. Microsoft SQL Server (MSSQL) Collation and Unicode Support
  6. Blank grid that Data is not showing up in MS SQL, MySql, DB2 or other database
  7. Display datagrid somewhere else on the page
  8. Foreign characters display
  9. How to wrap text in a cell?
  10. I have 3 different status (1,2 and 3) - I want to assign values to each.. active, inactive and archived .. how do I do this? If I set conditional statement , only the latest value works
  11. I want checkbox columns to display as checkboxes, not 1's and 0's.
  12. Refresh without post
  13. set_locale not working
  14. Customize Edit Form Layout
  15. How to sort phpGrid Data on two columns
  16. Column Order Position
  17. How to "crop" text so that the text won't wrap
  18. How to format text capitalization and other formats
  19. Always Display Integrated Search Toolbar When Page Load
  20. Can Virtual Column Be Used to Create New Column for Database Table?
  21. How to change the height of a row (not header row but data row)?
  22. Replacing Hyperlinks with Images
  23. Fix group sum floating (decimal) issue
  24. Resize Grid According to Current Screen Size
  25. Format UNIX Timestamp to Human Readable Time Format Using Custom Formatter
  26. Change Master Detail Grid Layout e.g. side by side
  27. Remove Duplicate Values in Group Summary
  28. Set Row Height
  29. Display a value in a cell that references a value in another table
  30. Mergy Multiple Columns in A Single Column
  31. Individual Column Color and Styling
  32. Set the grid width to the parent DIV
  33. Make Change to phpGrid Default CSS stylesheet
  34. grid width issue
  35. PHPGrid to go to a specific page during load
  36. Example not working
  37. I just want to be able to adjust hours and minutes.
  38. Data bar solid color?
  39. Conditional format - compare two cells
  40. Escape HTML characters in datagrid
  41. Elongated grid when theme is set
  42. How to display total sum of a column of ALL the records in the footer?
  43. Set datagrid to the width of its parent DIV
  44. Display group summary without any detail records
  45. Remove horizontal scroll when set_autowidth() is set to true
  46. Displaying Header vertically
  47. HTML source is displayed with WYSIWYG
  48. How to add a row called total automatically?
  49. Adding Totals on Local Array
  50. Display multiple grids from the same database table
  51. autocomple off
  52. Go to the last page on grid load
  53. Default to last page on page load
  54. Force Text to Upper Case Upon Submit
  55. Set Scroll while freezing columns
  56. The edit form missing scroll bar when form is longer than the page
  57. Center Edit Form and Display Scroll Bar in Bootstrap Theme
  58. Completely hide parent container's horizontal scrollbar
  59. How to center modal/pop-up edit form
  60. The bottom of the grid has too much space
  61. Unnecessary Space at the bottom of the phpGrid page
  62. Moved from mySQL to MSSQL showing "undefined" error message
  63. How to set up a hidden column to be searchable in advanced search?
  64. How to set up a hidden column to be searchable in advanced search?

Feedback and Knowledge Base