JQuery datepicker
-
The table column is of type date
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
"date" has a "one day resolution". Perhaps a (internal) rounding thing going from one representation to another.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
"date" has a "one day resolution". Perhaps a (internal) rounding thing going from one representation to another.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
"date" has a "one day resolution". Perhaps a (internal) rounding thing going from one representation to another.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
Hi and thanks for replying. So you have a better understanding I list out below what is happening.. The data is input and posted using a Razor page. The Web app Controller action issues a TryUpdateModelAsync which populates an instance of my class with the form data - at this point the date in the class is correct. I then pass my class object to an API running on my local LAN which pushes the data to a database , at this point the date in the class object has changed. So on it's journey to the API it is somehow changing the date. Both the Web app and the API are hosted on a Linux box.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
-
pkfox wrote:
So on it's journey to the API it is somehow changing the date.
Are you using a JSON serializer? That can do it.
Yes the API uses the NewtonSoft serialiser / deserialiser - weird that the date is always a day out. But as I said in another reply - I called the API from Postman ( hard coded JSON in the body ) and it worked as expected.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
-
Yes the API uses the NewtonSoft serialiser / deserialiser - weird that the date is always a day out. But as I said in another reply - I called the API from Postman ( hard coded JSON in the body ) and it worked as expected.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
pkfox wrote:
I called the API from Postman ( hard coded JSON in the body ) and it worked as expected.
Precisely. JSON sees 2021-06-14 00:00:00 AS UTC time and converts it for you. I don't remember how to get around it but if you google it, you should find it.
-
pkfox wrote:
I called the API from Postman ( hard coded JSON in the body ) and it worked as expected.
Precisely. JSON sees 2021-06-14 00:00:00 AS UTC time and converts it for you. I don't remember how to get around it but if you google it, you should find it.
-
I use RestSharp in my API which I believe uses a JsonSerialiser / JsonDeserialiser - do you think this is where the problem lies ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
-
I think I've got things working. After your suggestion that it could be a serializing problem I googled and found a post written by one of the RestSharp developers regarding the use of custom serializers, he gave some sample code which I duly cut'n pasted and it seems to have done the trick. Thanks very much for pointing me in the right direction.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
-
I think I've got things working. After your suggestion that it could be a serializing problem I googled and found a post written by one of the RestSharp developers regarding the use of custom serializers, he gave some sample code which I duly cut'n pasted and it seems to have done the trick. Thanks very much for pointing me in the right direction.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
-
While I have your ear - how can I set the datepicker to the date value in my model when I'm editing - I've tried the code below but it just shows a text box with the string dd-mm-yyy in until I click in it and then it pops up
@Html.TextBoxFor(m => m.DateUsed, new { @class = "datepicker", Type = "date", Value = Model.DateUsed }) -- DateUsed is my DateTime property
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
-
While I have your ear - how can I set the datepicker to the date value in my model when I'm editing - I've tried the code below but it just shows a text box with the string dd-mm-yyy in until I click in it and then it pops up
@Html.TextBoxFor(m => m.DateUsed, new { @class = "datepicker", Type = "date", Value = Model.DateUsed }) -- DateUsed is my DateTime property
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP