Thursday, March 21, 2024

How to format datetime stamp in JS like it is doing by the date template tag?

Hello, 

I have customizing Django admin by adding a datetime stamp to the page using JavaScript. I want to format the datetime stamp according to the format set by Django. 

It is possible to get the DATETIME_FORMAT using the get_format() method in JS. But, this format is not supported by the Date().srftime method. 

I don't want to hard-code the formatting of the datetime string. I want the code to adapt according to the Django settings for LANGUAGE_CODE, USE_I18N, and USE_L10N settings.

TIA! 

Regards,
Gagan Deep

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cab2283d-c0dd-40d2-a82e-6a5dce675038n%40googlegroups.com.

No comments:

Post a Comment