0

I have formatted a string date into date format
by using

<script type="text/javascript">  
var st = "26-04-2013";
var pattern = /(\d{2})\-(\d{2})-(\d{4})/;
var dt = new Date(st.replace(pattern,'$3-$2-$1'));
alert(dt);
</script>

and it's output is

Fri Apr 26 2013 05:30:00 GMT+0530 (IST)

but I want out put as 2013-04-26

how can i do this in JS?
urgent please :(

Edited by pritaeas: Fixed title typo.

2
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by Priti_P
0

urgent please :(

Not to us. No need to say this - it's just annoying.

<script type="text/javascript">  
var st = "26-04-2013";
var pattern = /(\d{2})\-(\d{2})-(\d{4})/;
var dt = st.replace(pattern,'$3-$2-$1');
alert(dt);
</script>
0

Thanks a lot!
it worked
and I will take of it next time :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.