0👍
You have to convert the C# DateTime-object to JavaScript Date-object. In JS you can create a Date object by passing in the number of milliseconds since 1 January 1970 (new Date(0) will give you 1970-01-01). For getting this number you can use an extension like:
public static class DateTimeExtensions
{
private static readonly long DatetimeMinTimeTicks =
(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).Ticks;
public static long ToJavaScriptMilliseconds(this DateTime dt)
{
return (long)((dt.ToUniversalTime().Ticks - DatetimeMinTimeTicks) / 10000);
}
}
So now you can in the backend do for instance:
long numberOfMilliseconds = DateTime.Now.ToJavaScriptMilliseconds(); //C#
And send that to the frontend so you can do this with JavaScript:
var myDate = new Date(editedItem.numberOfMilliseconds); //JavaScript
- [Vuejs]-Vue js multiselect edit form not showing data
- [Vuejs]-Is there a way to make a slide transition that makes the elements go below the border?
Source:stackexchange.com