I am able to convert timestamp to datetime from this question:
Convert a Unix timestamp to time in JavaScript
But how to convert it in table? Calling the javascript function within the table row doesnt work
<body>
<table id="resulttable" class="display">
<thead>
<td>Date</td>
<td>Booking ID</td>
<td>Name</td>
<td>Phone</td>
<td>Email</td>
<td>Amount</td>
<td>Type</td>
</thead>
<tbody>
<apex:repeat id="repeatdata" var="dt" value="{!resultList}">
<tr>
<td>
convertTimestamp({!dt.timestamp});
</td>
<td>{!dt.bookingId}</td>
<td>{!dt.name}</td>
<td>{!dt.phone}</td>
<td>{!dt.email}</td>
<td>{!dt.amount}</td>
<td>{!dt.productType}</td>
</tr>
</apex:repeat>
</tbody>
</table>
javascript:
function addZero(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function convertTimestamp(pTimestamp) {
var result = new Date(pTimestamp);
var dd = addZero(result.getDate());
var mm = addZero(result.getMonth()+1); //January is 0!
var yyyy = result.getFullYear();
var HH = addZero(result.getHours());
var min = addZero(result.getMinutes());
result = yyyy + '/' + mm + '/' + dd + ' ' + HH + ':' + min;
return result;
}
Basically, I want to convert timestamp:
convertTimestamp(1488966492914);
to:
2017/03/08 04:48
in all list of record inside the table based on parameter inputted in javascript parameter value.
How can I achieve this?