dipti dipti - 1 year ago 50
Javascript Question

I want to call a javascript function in a table td in php

I want to call a javascript function from a table td and pass this td value as parameter of this javascript function. this is my script and table.

<table width="100%" class="track">
<th colspan="2">Load Information</th>
<td>LOAD DATE:</td>
<td id="ldate"><?php echo $datas[0]->DATE?> </td>
function formatDate(date_string) {
var date = new Date(date_string);
var monthNames = [
"January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December"
var day = date.getDate();
var monthIndex = date.getMonth();
var year = date.getFullYear();

if (day < 10) {
day = '0' + day;
return monthNames[monthIndex] + ' ' + day + ', ' + year ;

I want to show a dateformat like MARCH 03,2016 ,but my actual format will show as 2016-03-03.

Answer Source

Use strtotime() and date() using PHP:

$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download