locked
How to get the server time in Dynamics CRM- ONLINE? RRS feed

  • Question

  • How to get the server time in Dynamics CRM- ONLINE?
    Thursday, March 16, 2017 7:09 AM

All replies

  • Hello,

    Where do you want to get that datetime?


    Dynamics CRM/Business Solutions MVP
    Read My blog

    Thursday, May 4, 2017 4:52 PM
    Moderator
  • Try getting it from custom workflow activity like:-

            public class GetCurrentPSTTime : CodeActivity
            {
                [Output("Current PST Time")]
                public OutArgument<String> CurrentPSTTime { get; set; }
                protected override void Execute(CodeActivityContext context)
                {
                    CurrentPSTTime.Set(context, DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                }
            }


    Regards Faisal

    Friday, May 5, 2017 8:53 AM
  • Try getting it from custom workflow activity like:-

            public class GetCurrentPSTTime : CodeActivity
            {
                [Output("Current PST Time")]
                public OutArgument<String> CurrentPSTTime { get; set; }
                protected override void Execute(CodeActivityContext context)
                {
                    CurrentPSTTime.Set(context, DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                }
            }


    Regards Faisal

    Faisal,

    Isn't following easier:

            public class GetCurrentPSTTime : CodeActivity
            {
                [Output("Current PST Time")]
                public OutArgument<DateTime> CurrentPSTTime { get; set; }
                protected override void Execute(CodeActivityContext context)
                {
                    CurrentPSTTime.Set(context, DateTime.Now);
                }
            }
    But this will work in workflows only. What if it is JavaScript? :) That's why I asked where topicstarter needs that value.


    Dynamics CRM/Business Solutions MVP
    Read My blog


    Friday, May 5, 2017 2:34 PM
    Moderator