Click here to Skip to main content
12,448,192 members (51,391 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Javascript
var CurDate = "2011.20.11";
var CDate = new Date(CurDate);
i have also try var CDate = (new Date(CurDate)).format("yyyy.dd.mm");
also Date.format("yyyy.dd.mm") but nothing work..
When i use Cdate it will return error as invaliddate().

please help me in this...

Regards,
Jatin
Posted 25-Apr-11 7:09am
Updated 25-Apr-11 16:01pm
thatraja248.3K
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

This[^] could help.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

use Date.parseDate(dateValue,format) method.

var d = Date.parseDate("2005-10-05 12:13 am", "Y-m-d g:i a");
document.write(d + "\n");
var d = Date.parseDate("9/5/05", "n/j/y");
document.write(d + "\n");
  Permalink  
Comments
jatinchandarana 25-Apr-11 13:25pm
   
Not Working....
When i write var d= Date.parseDate("2011.11.02","yyyy.mm.dd");
it gives me this error
TypeError: Date.parseDate is not a function
Wonde Tadesse 6-Dec-11 10:22am
   
Just refer the following date format options.
http://www.webdevelopersnotes.com/tips/html/10_ways_to_format_time_and_date_using_javascript.php3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

Add these two script file in your page
if you don't have these Script plugin then go through these link and download it first.
@download[^]


And try like this it will work 100%

 <script language="javascript" type="text/javascript" src="~/Scripts/date.js"></script>
    <script language="javascript" type="text/javascript" src="~/Scripts/time.js"></script>
 

var today = Date.today();
        $('#EndDateConsumption').val(today.toString("MM/dd/yyyy"));
        var $startDate = $('#EndDateConsumption');
        var $endDate = $('#StartDateConsumption');
        var dStartDate = Date.parseExact($startDate.val(), "MM/dd/yyyy");
        var prevDate = dStartDate.add(-1).months();
        $endDate.val(prevDate.toString("MM/dd/yyyy"));

Enjoy Smile | :)
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 25 Sep 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100