1

I have converted UTC time to local time by this snippet:

var dateLocal = new Date(startDate).toString();

and this's my result: Wed Apr 24 2013 10:42:45 GMT+0700 (SE Asia Standard Time) I want to format my result to: MM/dd/yyyy HH:mm:ss

4
  • You should do it either by hand or I propose using date.js
    – Nemoden
    Apr 24, 2013 at 3:53
  • I don't want to use another scrip, just jQuery
    – Aka Shiro
    Apr 24, 2013 at 3:54
  • Ok, do it by hand then. I mean there is no special features in jQuery for handling "datetimes".
    – Nemoden
    Apr 24, 2013 at 3:54
  • jQuery Is a JavaScript library that abstracts DOM manipulation. jQuery does not include much built-in functionality for manipulating objects outside of that scope, including dates. You'll either have to use the native JavaScript date methods or include a separate Date library.
    – gilly3
    Apr 24, 2013 at 4:17

2 Answers 2

0

you can do it with pure javascript. I dont thing jquery could help here.

var dateString = (dateLocal.getMonth() + 1) + "/" + dateLocal.getDate() + "/" + dateLocal.getFullYear()+" "+dateLocal.getHours() + ":" + dateLocal.getMinutes() + ":" + dateLocal.getSeconds() ;

here is a fiddle

also there appears to be a jquery plugin for formating date strings.

0

Use the date.js and then try with the following code

Date.parse(startDate).toString('MM/dd/yyyy H:i:s')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.