0

Looking for help!!! I'm using REST API to retrieve SharePoint list items. Date time field returns value in 2016-10-01T16:00:00Z. Is there a way to retrieve date in dd/mm/yyyy hh:mm AM/PM format or convert the date to required format using jquery.

Thanks

  • Please refer this link --> http://stackoverflow.com/questions/23946698/changing-date-time-format-using-jquery-javascript – Rohit Waghela Oct 03 '16 at 09:16

1 Answers1

0

I'd advise you to have a look at the library Moment.js.

You can parse the input string with it as it is explain in the library doc.

Add the library to your <head> like: <script type="text/javascript" src="[If not in the folder containing your html file, specifiy your path beneath the folder containing it + "/"]moment-with-locales.min.js"></script>

Then in your <body> try:

<script type="text/javascript"> var test = moment("2016-10-01T16:00:00Z").format('DD/MM/YYYY hh:mm:ss A'); alert("test: " + test); </script>

It will display: "Test: 01/10/2016 06:00:00 PM"

It shows 6pm because I am located at UTC+2 hours.

nyluje
  • 3,573
  • 7
  • 37
  • 67
  • You're welcome, since it is the solution to your problem, could you validate answer and upvote it so we both earn reputation:) – nyluje Oct 04 '16 at 11:40