[Vuejs]-Formatting date time formatting javascript function in .vue to server side entity framework query

0👍

When formatting DateTime.ToString() you have to follow a specific format..

This article outlines the formatting characters..

Below shows how to convert DateTime to string format from ticks as well as a DateTime object itself..

Run this example online via DotNetFiddle.net

using System;

namespace Root
{
    public class Program
    {
        public static void Main()
        {
            /** could also do:
            var nowInTicks = DateTime.Now.Ticks; */
            var nowInTicks = 636905426867055839;
            var nowString = new DateTime(nowInTicks).ToString("MM/dd/yyyy");
            Console.WriteLine(nowString);
            Console.WriteLine(DateTime.Now.ToString("MM/dd/yyyy hh:mm:sstt"));
        }
    }
}
/* RETURN: */
// 04/11/2019
// 04/11/2019 01:32:28AM // in UTC

Leave a comment