web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Date Time format - JavaScript

(0) ShareShare
ReportReport
Posted on by 894

Hi -
I have a datetime field in which I'm using in a JavaScript function:

function getDate()
{
valu :- /Date(1509696000000)/ get crm datetime field Fri Nov 03 2017 13:30:00 GMT+0530

var date =
eval('new ' +
value.replace("/", "").replace("/", ""));
return date.format('yyyy-MM-dd hh:mm:ss tt');
alert (date)
}

The alert displays the the format of the field as this: date = 11/4/2017 1:30 PM

I need to reformat the result to show as this same value time(11/4/2017 8:00 AM) but current I got value (11/4/2017 1:30 PM) I think (plus + 5.30 hour add), so I can use it in a further part of the function.
Does anyone know how to do this in the JavaScript function?
Thanks,

*This post is locked for comments

I have the same question (0)
  • shivaram Profile Picture
    3,315 on at

    Hi,

    you entered Time as 13:30 (or you gave date value as like that). if you want 8'o clock just substract accodingly..

  • Verified answer
    Community Member Profile Picture
    on at

    Hi CRM Developer,

    you could try with moment library:

    https://momentjs.com/ 

    using the following code:

    moment.tz.setDefault("America/New_York"); // <-- put here your timezone
    date = moment(yourdatestring, "MM/DD/YYYY HH:mm a").tz("UTC");

    Please let me know.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • CRM Develope Profile Picture
    894 on at

    Thanks Francesco Picchi

    It's working fine

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans