views:

55

answers:

3

I can't find a good jquery date and time that displays my selected date and time like this
11-Aug-2010 12:30:38. Any good one you have seen...

A: 

Not the prettiest, but this works:

function getDateStr()
{
  var d=new Date();
  var m=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  return len(d.getDate())+'-'+m[d.getMonth()]+'-'+d.getFullYear()+' '+len(d.getHours())+':'+len(d.getMinutes())+':'+len(d.getSeconds());
}

function len(s)
{
  if((s+' ').length<3)
  {
    return '0'+s;
  }
  return s;
}

Call getDateStr() to receive the date in that format.

Kranu
A: 

http://jqueryui.com/ has the best datepicker IMO!

Tim