How to put system date and time in input?

48 views
Skip to first unread message

Matheus Bon

unread,
Oct 5, 2022, 1:55:29 PM10/5/22
to Django users
Hi guys!

I need for my project to get the system date and time and put this value inside an input through value.

Well, I tried some methods like:

{% load tz %}

<input value = " {{ value|localtime }} " >

And other ways, however it never works.

I went to test to see if the problem was in the input and value, I put this: <input value = " {{ request.user }} " > and it worked, my user appeared in the input.

What should I do?


Note: In settings.py I put USE_TZ = True

Ali Axghar

unread,
Oct 6, 2022, 10:26:42 AM10/6/22
to Django users
{{value|date:'m-d-Y h:m:s'}}

Isaac Muturi

unread,
Oct 6, 2022, 10:26:43 AM10/6/22
to django...@googlegroups.com
Try:
<input type="hidden" name="localusertime" value="{% now "jS F Y H:i" %}">

Best wishes.

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c9e52cce-0453-48d0-98f3-b88662ca7b90n%40googlegroups.com.

Matheus Bon

unread,
Oct 6, 2022, 4:50:28 PM10/6/22
to django...@googlegroups.com
Thanks for your reply friend, it really worked!

However, another problem arose, when I edit this element, this occurs:



You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/DkZ_TYKO4Kg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOfijSdOZ47Y48ujQceaisGD0kRzLu7xmG5XaLSZpQ7JnAMttQ%40mail.gmail.com.
Screenshot from 2022-10-06 17-47-51.png
Reply all
Reply to author
Forward
0 new messages