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

date format using Java script

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

Re: date format using Java script

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

 

Thanks,

Vibhuti

Re: date format using Java script

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

Re: date format using Java script

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