Click to See Complete Forum and Search --> : Date formatting


anarchist
05-13-2003, 10:26 AM
I have a date stored in the format "Fri May 9 00:00:00 UTC+0100 2003", I'm looking for an easy way of formatting to something like dd/mm/yyyy hh:mm:ss as this will be easier to display
I know I can use the date object, but am unsure about how to use it

any help will be appreciated

khalidali63
05-13-2003, 10:44 AM
you can do that may be using something like this
<script type="text/javascript">
Date.prototype.getRegularDateTime = function(){
return this.getDate() + "/" +
(this.getMonth()+1) + "/" +
this.getFullYear() + " " +
this.getHours()+ ":" + this.getMinutes() +
":"+this.getSeconds();
}
function Process(){
var now = new Date();
alert(now.getRegularDateTime());
}
</script>
</head>

<body onclick="Process();">

anarchist
05-13-2003, 10:51 AM
thanx for the output help
quick question if I creted the obejct like

var now= new Date("Fri May 9 00:00:00 UTC+0100 2003")

will this work? so I can then use your funtion to set the format

khalidali63
05-13-2003, 10:56 AM
you can ,but it has some serious limitations,
look into
Date.parse('format')
function at this link

http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/date.html#1194184

anarchist
05-13-2003, 11:29 AM
cheers that looks like it'll help loads thanks