You need to sign in to do that
Don't have an account?

Date to String in JavaScript Remoting
Hi folks,
Can anyone tell me how to convert the date format to string format in JavaScript Remoting?
Below is my code
The above code gives alert message like 731808000000
But my actual birthdate is 22/11/1992
I dono how to convert the date to string ?
Thanks in advance
Karthick
Can anyone tell me how to convert the date format to string format in JavaScript Remoting?
Below is my code
@RemoteAction global static theHRMS__Employee__c getEmployee() { Contact c=[select birthdate__c from contact where id=0039000001CoN3m]; return c; } My VFP: Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.NewUIEmployeeContr.getEmployee}', function(result, event){ if (event.status) { Var bdate=result.birthdate__c ; alert(bdate); }
The above code gives alert message like 731808000000
But my actual birthdate is 22/11/1992
I dono how to convert the date to string ?
Thanks in advance
Karthick
Use following code
If the input is 731808000000 , then the result in the popup you will get "11/3/1993";(In dd/mm/yyyy format).
Regards,
Amritesh
All Answers
Use following code
If the input is 731808000000 , then the result in the popup you will get "11/3/1993";(In dd/mm/yyyy format).
Regards,
Amritesh
Thanks for your response.
Can you tell me how it works?
Whats the purpose of d.getmonth()+1 ...
Thanks in advance
Karthick
The number '731808000000' is in milliseconds. (JavaScript dates are calculated in milliseconds from 01 January, 1970 00:00:00 Universal Time).
So we created 'd' date type using the number.
Now the actual date is stored in d, we fetched the date using d.getDate() and so on.
d.getMonth() returns value inrange of 0-11, so to get actual month I had to increment it.
To know about javascript Date methods, follow link
http://www.w3schools.com/jsref/jsref_obj_date.asp
Thanks,
Amritesh