I've been trying to output a time in my website. In my localhost it renders/runs fine but when I uploaded my file to another environment/server it yields the error "String was not recognized as a valid DateTime." I assume it's because the culture of datetime/timezone of the machine(my laptop) I'm using and the other server are different. What should I alter with my codes to matched with the server?
DateTime starttime;
DateTime endtime;
starttime = Convert.ToDateTime(tempstarttime);
tempstarttime = starttime.ToString();
endtime = Convert.ToDateTime(tempendtime);
tempendtime = starttime.ToString();
if (schedlist[i, 2] == "PM" && schedlist[i + 1, 2] == "AM")
{
//reformat schedlist[i+1, 2] to next day date + schedlist[i, 1]
endtime = endtime.AddDays(1);
exceedtonextday = 1;
}
if (exceedtonextday == 1)
{
endtime = endtime.AddDays(1);
starttime = starttime.AddDays(1);
}
if (comparetimesched(starttime, endtime))
{
currentshow = "<span>" + schedlist[i, 1] + " " + schedlist[i, 2] + "</span><p>" + schedlist[i, 0] + "</p>";
nextshow = "<span>" + schedlist[i + 1, 1] + " " + schedlist[i + 1, 2] + "</span><p>" + schedlist[i + 1, 0] + "</p>";
showingimage = schedlist[i, 4];
showingimagetwo = schedlist[i + 1, 4];
}