Skip to main content
1-Visitor
August 13, 2019
Question

date format using Java script

  • August 13, 2019
  • 3 replies
  • 1250 views

Hi,

I wanted to return current date and time in August 13, 2019 03:54 PM format using Java script.Could someone help me in achieving this because I am not able to find the appropriate js to achieve this format.

Thanks in advance,

Shalini V.


 
 

3 replies

16-Pearl
August 13, 2019

Hi @svisveswaraiya_285988  You may refer to this article to get more information. Hope this is helpful.

 

Thanks,

Vibhuti

18-Opal
August 14, 2019

Hello,

 

Try this (format string syntax is explained here😞

 

var result = dateFormat(new Date(), "MMMMM d, yyyy hh:mm a");

 

 

Note that formatting date/time on the server side is almost always a bad idea, because for doing so it uses server time zone (typically GMT). In most cases you should rather format it in a mashup (widgets like Grid, Value Display and others support time formatting on the client side in a similar fashion, thus automatically adjusting to the user's time zone). Few cases when you need to format date/time on the server side include sending emails, SMS, etc. -- but in this case please double-check the timezones and make sure you handle things like DST.

 

Regards,
Constantine

5-Regular Member
August 16, 2019

Hello svisveswaraiya,


If the responses has answered your question, please mark it as an Accepted Solution for the benefit of others who may have the same question in the future.

Thank you for your contributions to the PTC Community.

Abarki