Time Format Problem
Hi guys;
I have a major problem with the datetime format.
I'm using a string called _PLC_ClockTime_Value and put it into "ClockTime".
This string can come in in many formats, and I what to specify that format in a Textbox (eg. MM/dd/yy HH:MM:ss) but frankly any format I specify in there I need to format into that format i put into the textbox.
Then it's converted into my format
My code look like this:
string ClockTimeInput = Convert.ToString(_PLC_ClockTime.Value);
DateTime ClockTime = DateTime.Parse(ClockTimeInput);
System.Globalization.DateTimeFormatInfo TimeFormat = new System.Globalization.DateTimeFormatInfo();
TimeFormat.FullDateTimePattern = (PLC_ClockTime_Format.Value.ToString());
DateTime NewTime = Convert.ToDateTime(ClockTime, TimeFormat);
LogInfo(NewTime.ToString("yyyy-MM-dd HH:mm:ss"));
LogInfo(NewTime.ToString());
DateTime SystemTime = DateTime.Now;
TimeSpan ElapsedTime = NewTime.Subtract(SystemTime);
double OffSet = ElapsedTime.TotalMinutes;
_PLC_ClockTimeOffset.Value = OffSet;
Please any help will be greatly valued.
Thankx
|