Date vs DateTime

后端 未结 12 1662
暖寄归人
暖寄归人 2020-11-30 05:13

I am working on a program that requires the date of an event to get returned.

I am looking for a Date, not a DateTime.

Is there

12条回答
  •  离开以前
    2020-11-30 05:50

    The DateTime object has a Property which returns only the date portion of the value.

        public static void Main()
    {
        System.DateTime _Now = DateAndTime.Now;
        Console.WriteLine("The Date and Time is " + _Now);
        //will return the date and time
        Console.WriteLine("The Date Only is " + _Now.Date);
        //will return only the date
        Console.Write("Press any key to continue . . . ");
        Console.ReadKey(true);
    }
    

提交回复
热议问题