using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using uDate;

namespace DateDiff_timeDiff
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            string s = DateTime.Now.ToLongTimeString();
            
            label1.Text ="London : " + s;
            DateTime p =DateTime.Now.AddHours(3) ;
            s = p.ToLongTimeString();
            label2.Text = "KSA : " + s;
            label6.Text = uDate.dt.TimeDiff(DateTime.Now,p);
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DateTime t1=dateTimePicker1.Value;
            DateTime t2=dateTimePicker2.Value;
           label3.Text= uDate.dt.DateDiff(t1, t2);
            
        }

        private void label1_Click(object sender, EventArgs e)
        {

            
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

      
    }
}

the problem : When taking the difference between the days gives me the difference after 24 hours i wana it give me the want to do and I count the number of days just to enter in the first hour of the day the new... can anyone help to know where's the mistake here....:)

Have you tried TimeSpan?

TimeSpan tm= dt1 - dt2;

I tried in this function but it didn't any thing...
I have this func:

public static string   DateDiff( DateTime t2,DateTime t1)
        {
            TimeSpan  diffResult = t2.Subtract(t1);
            int i = diffResult.days;
            
       
            return i.ToString();

        }

but dont know what i have to do to get the days numb..

Have you tried diffResult.TotalDays? .Days only returns the day portion of the timespan, so if the difference between the dates was 1 month, 1 week and 1 day then .Days would return 1 whereas TotalDays would return 39 or something close to it depending on the dates you were comparing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.