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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans