How to convert String to date formate

13 Aug, 2018


You are welcome~ =) LikeLike This script works except that it sets j Mon Dec 31 19:00:00 EST 2012 on my machine This is because the () function assumes Zulu (GST) time and my machine is running EST (GST-5) var this = '2013-01-01T00:00:00';var j = new (this);alert(j); Note that there is a "T" between the and time You can simply substring the text data apart insert the "T" and you'll be all set If you need do this repeatedly a little function makes it easy of course var this = "2013-01-01 00:00:00";var thisT = (0 10) + "T" + (11 8);alert(thisT);var j = new (thisT);alert(j); If you want a specific timezone you'll need do that manipulation as. Sympraxis Consulting LLC - Marc D Anderson's Blog - @sympmarc - jQuery Library for SharePoint Web Services (SPServices) Thanks for your suggestion~ =) LikeLike Please refer – Create a object from a string LikeLike Join 834 other followers Thanx this helped LikeLike The following piece of code shows you how get the YYYY-MM-DD formatted string from a Object // GET CURRENT var = new (); // GET YYYY MM AND DD FROM THE OBJECT var yyyy = getFullYear().String(); var mm = (.getMonth()+1).String(); var dd = get().String(); // mm AND dd IN chars var mmChars = (''); var ddChars = (''); // CONCAT THE STRINGS IN YYYY-MM-DD FORMAT var string = yyyy + '-' + (mmChars[1]?mm:"0"+mmChars[0]) + '-' + (ddChars[1]?dd:"0"+ddChars[0]);   Done =) Reference: StackOverflow – Get String in format from JS object? You are commenting using your Facebook account ( Log Out /  Change ) The output is of string there any way string object with the dd/MM/yyyy format and output after format change is of type and not of string LikeLike This script works except that it sets j Mon Dec 31 19:00:00 EST 2012 on my machine This is because the () function assumes Zulu (GST) time and my machine is running EST (GST-5) var this = '2013-01-01T00:00:00';var j = new (this);alert(j); Note that there is a "T" between the and time You can simply substring the text data apart insert the "T" and you'll be all set If you need do this repeatedly a little function makes it easy of course var this = "2013-01-01 00:00:00";var thisT = (0 10) + "T" + (11 8);alert(thisT);var j = new (thisT);alert(j); If you want a specific timezone you'll need do that manipulation as. Thank you very much… this is very helpful for me… LikeLike

It’s great There is some online ols like time formatter it’s easy use LikeLike Hi I have string '2013-01-01 00:00:00' Can anyone help me. Sympraxis Consulting LLC - Marc D Anderson's Blog - @sympmarc - jQuery Library for SharePoint Web Services (SPServices) Sign in post your reply or Sign up for a account. This site uses Akismet reduce spam Learn how your comment data is processed Dream BIG and go for it =) Subscribe Eureka! Enter your email address subscribe this blog and receive notifications of new posts. Var = (new ()).ISOString().split(‘T’)[0]; LikeLike Good know that it helps =D LikeLike

Hey The best you can do is use the ISO format YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS For example: new ('2011-04-11') or new ('2011-04-11T11:51:00') or I think this can help you: /// There's a getFromFormat() function that you can tweak a little solve your problem Up: there's an upd version of the samples available at Let me know if you have any queries :) "The Only Way Get Smarter Is By Playing A Smarter Opponent" Fill in your details below or click an icon. Notify me of new comments via email Notify me of new posts.