title: How to work with DateTime.Now to ticks
body: <p>I'm trying to add the phones current time to my date time list. I need it to be able to subtract with the ticks. I have tried using <code>phonecurrentime.ToString("dd hh:mm");</code> but because it's a string there are no ticks and all sorts of errors!</p>
  
  <p>I need it to work with <code>DateTime.now</code>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>InitializeComponent();
  
  List&lt;DateTime&gt; theDates = new List&lt;DateTime&gt;();
  DateTime fileDate, closestDate;
  
  theDates.Add(new DateTime(2000, 1, 1, 10, 29, 0));
  theDates.Add(new DateTime(2000, 1, 1, 3, 29, 0));
  theDates.Add(new DateTime(2000, 1, 1, 3, 29, 0));
  
  // This is the date that should be found
  theDates.Add(new DateTime(2000, 1, 1, 4, 22, 0));
  
  // This is the date you want to find the closest one to
  fileDate = DateTime.Now;
  
  long min = long.MaxValue;
  
  foreach (DateTime date in theDates)
  {
      if (Math.Abs(date.Ticks - fileDate.Ticks) &lt; min)
      {
          min = Math.Abs(date.Ticks - fileDate.Ticks);
          closestDate = date;
      }
  }
  </code></pre>