Create a TimeSpan representing 1 week : TimeSpan : Date Time C# Examples


C# Examples » Date Time » TimeSpan »

 

Create a TimeSpan representing 1 week









    
using  System;
class  MainClass
{
        public  static  void  Main(string[]  args)
        {
                
                TimeSpan  oneWeek  =  new  TimeSpan(4,  12,  0,  0)  +  new  TimeSpan(2,  12,  0,  0);
                        
                //  Create  a  DateTime  with  the  current  date  and  time.
                DateTime  now  =  DateTime.Now;

                //  Create  a  DateTime  representing  1  week  in  the  future.
                DateTime  future  =  now  +  oneWeek;
        
                Console.WriteLine("Future:  {0}",  future);        
        }
}
    
   
  
   



Output

Future: 01/04/2007 2:10:53 PM


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Date Time
» TimeSpan