views:

214

answers:

1

my date of string like (2009-12-03 21:05:00) date with time . so i used to store var newdate:Date=new Date(Date.parse(startdate)); but shows some errors.

and also i tried to split string(date) used date function like

var datenumber:Number= (new Date(Date.parse(startdate))).getDate();

not get the date how can i split particular date only ? plz kindly refer me

+1  A: 

Problem is with the dashes (-). Use 2009/12/03 21:05:00 instead.

In the string given to the Date.parse() method, the year, month and day terms can be separated by a forward slash (/) or by spaces, but never by a dash (-). Supported formats include the following: (you can include partial representations of these formats; that is, just the month, day, and year)

Day Mon DD HH:MM:SS TZD YYYY
MM/DD/YYYY HH:MM:SS TZD
HH:MM:SS TZD Day Mon/DD/YYYY
Mon DD YYYY HH:MM:SS TZD
Day Mon DD HH:MM:SS TZD YYYY
Day DD Mon HH:MM:SS TZD YYYY
Mon/DD/YYYY HH:MM:SS TZD
YYYY/MM/DD HH:MM:SS TZD

You can change the format of the string using a simple regex:

dateString = dateString.replace(/-/g, "/");
Amarghosh
this (2009-12-03 21:05:00) instead got from webservice . so how can i changed to new format of '/' 2009/12/03 21:05:00
R.Vijayakumar
replace `-` with `/` using a regex - see my update
Amarghosh
thanks for your value information MR. Amarghosh
R.Vijayakumar