Question: I am on a simulation application and need to attach different time with each record. I am storing the date and time in separate strings:

```
string pdate = DateTime.Now.ToShortDateString();  
string ptime = DateTime.Now.ToShortTimeString();

```

Now I am trying to add 5 minutes to the ptime variable (this I am doing in a foreach loop). 

```
foreach (loaddata dl2 in lstdata)
{
  //some code
  ptime = DateTime.Now.AddMinutes(5); 
  //Results in ptime with date and time(I only need the time here)
}

```

**UPDATE:** I need to add 5 minutes to the previous time in each iteration

Suggestions please.

Answer: 
Do this way

```
ptime = DateTime.Parse(ptime, "your string format", CultureInfo.InvariantCulture)
                .AddMinutes(5).ToShortDateString();

```

**Problem with your code**

Store DateTime in DateTime only so you can "increment" them there itself.
Converting from DateTime to string is easy and almost error free. But conversion from string to Dateime sometimes results in exception.

Best is to do it this way

```
DateTime ptime = DateTime.Now;

// After some coding

ptime = ptime.AddMinutes(5);

```

Conversion to string should be done when you know that DateTime Format is not required like showing in UI.
Use a `DateTime` object:

```
DateTime current = DateTime.Now;

foreach (loaddata dl2 in lstdata)
{

   //some code
   current = DateTime.Now.AddMinutes(5); 

   string pdate = current.ToShortDateString();  
   string ptime = current.ToShortTimeString();
   // do something with pdate and ptime

   //Results in ptime with date and time(I only need the time here)
}

```