cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

date format using Java script

svisveswaraiya
17-Peridot

date format using Java script

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 3

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

 

Thanks,

Vibhuti

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

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

Top Tags