PDA

View Full Version : Date in SQL Format (opt. with grid renderer)



Wolfgang
13 Jan 2007, 5:56 AM
The following simple code returns the current date in the sql like format yyyy-mm-dd hh:mm


formattedDate = (new Date()).dateFormat('Y-m-j G:i');


...and this renderer can be used in a grid to show y-m-d in bold:


// render date with bold dd:mm:yy
YAHOO.ext.grid.LoggerListCM.prototype.renDate = function (formattedDate) {
// sep. date and time
var dd = date.split(" ");
var ar = dd[0].split("-");
return "" + ar[2] + "-" + ar[1] + "-" + ar[0] + " [" + dd[1] + "]";
};