Ruby on Rails : Date.today differs from Date.current

Date.current also returns Date.today if timeZone is not set other wise returns Today's Date of current time zone. We can verify this by changing the timezone.
Continue reading

Advertisements

jQuery DataTables : Ruby On Rails : Sorting of date/time column in any format : Type based sorting

//cdn.datatables.net/plug-ins/1.10.7/sorting/datetime-moment.js

1
2
3
4
5
6
7
8
9
10
11
<script type="text/javascript" src="jquery.dataTables.js"></script>
<script type="text/javascript" src="dataTables.numericComma.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#example').dataTable( {
            "columnDefs": [
                { "type": "numeric-comma", targets: 3 }
            ]
        } );
    } );
</script>
$.fn.dataTable.moment( '%B %e, %Y' ); // Format I used for date
$targetTable.dataTable({ /* Disable initial sort */
 "aaSorting": [],
 "order": [],
 "aoColumnDefs": [
   {
   'bSortable': false,
   'aTargets': ['action']
    }, 
   {
   "type": "datetime-moment", //use moment.js to calulate and sort date col
   targets: ['created-on', 'last-sent-on', 'date-applied']
   }
 ],
 'iDisplayLength': 10
});
<table id="bench-applicants-table">
 <thead>
 <tr>
 <th><%= t(:id) %></th>
 <th><%= t(:name) %></th>
 <th><%= t(:job_applied) %></th>
 <th><%= t(:status) %></th>
 <th><%= t(:number_of_email_sent) %></th>
 <th class="last-sent-on"><%= t(:last_sent_on) %></th>
 <th class="action"><%= t(:action) %></th>
 </tr>
 </thead>

similarly,
<th class="created-on"><%= t(:created_on) %></th>

Source: http://datatables.net/plug-ins/sorting/datetime-moment

http://datatables.net/plug-ins/sorting/