Adam.13
Adam.13

Reputation: 41

JQuery Mobile DateTime set to current

Hi there I am using JQuery mobile to create a small app. For a part of the app I want to display the date and time to the user and them be unable to edit this. Currently I just have this:

div data-role="fieldcontain" class="ui-field-contain ui-body ui-br">Date:<br>
  <input type="datetime-local" name="date" id="date" value="" class="ui-input-text ui-body-c ui-corner-all ui-shadow-inset">
</div>

I want to set this to the current date and time instead of the user being able to select for themselves. I have had a search but don't seem to be able to find much. I would really appreciate any help with this.

Upvotes: 0

Views: 1104

Answers (1)

ho.s
ho.s

Reputation: 751

as Rup mentioned, you should rather use a span eg than an input element, if the date is just displayed. input makes no sense if nothing is meant to be "put in" (semantics..). You could generate the current Date with javascript simply using the Date() object and then append it to your (span)element. Maybe you'll find this answer helpful: javascript date object

Upvotes: 1

Related Questions