Change Time of DateTime - CSharp System

CSharp examples for System:DateTime Calculate

Description

Change Time of DateTime

Demo Code


using System.Collections.Generic;
using System;/*from w ww.  ja v a  2  s  .co  m*/

public class Main{
        public static DateTime ChangeTime(this DateTime dateTime, int hours, int minutes, int seconds, int milliseconds)
        {
            return new DateTime(
                dateTime.Year,
                dateTime.Month,
                dateTime.Day,
                hours,
                minutes,
                seconds,
                milliseconds,
                dateTime.Kind);
        }
}

Related Tutorials