You can use this code in C#.
DateTime datefrom = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));
DateTime dateto = DateTime.Now;
TimeSpan tmp = dateto - datefrom;
long diff = (long)tmp.TotalMinutes;
long diff = (long)(dateto - datefrom).TotalMinutes;