C # Convert.ToDateTime() problem - c#-2.0

I read date string from the text file.
eg. string date="12/02/2010 13:23:00 AM" (read from the text file).
Then, I just try to convert it to date using DateTime dt= Convert.ToDateTime(date);
If I run in Visual Studio, it's ok. But after installing this setup and If i run the exe, the date time format exception pop up. Any idea? thanks.

13:23:00 AM is not a valid time. It is essentially saying "1:23:00 PM AM".

Hey The Input string is wrong. It should be 2/02/2010 13:23:00 PM and not 2/02/2010 13:23:00 AM
DateTime dt= Convert.ToDateTime("2/02/2010 13:23:00 PM");
AM - 00 to 12 hrs
PM - 13 to 24 hrs

Related

Using TimeZone with PipeDate in Angular 6 not working?

I am using DatePipe to display Epoch time, the milliseconds time is in UTC, I want to keep it display on UTC so I am setting timezone option is '0'.
Here is my code:
<span class="description">{{epochTime | date:'dd/MM/yy hh:mm a':'0'}}</span>
with 'epochTime' = '1570274515223' <=> 'Sat Oct 05 2019 11:21:55 AM'.
But on the UI is: '05/10/19 06:21 PM'
It is getting local time zone here. Why I can not force pipe to use UTC time?
'0' is not valid. Instead, specify the offset in one of the following ways: 0, '+0','+00:00', 'UTC'

How do I get a Date from Milliseconds (since epoch)?

I got 1234567890123 milliseconds from DateTime.now().millisecondsSinceEpoch.
How do I get Fri Feb 13 2009 23:31:30 in UTC time from that?
DateTime has a constructor called DateTime.fromMillisecondsSinceEpoch.
DateTime.fromMillisecondsSinceEpoch(1234567890123, isUtc: true).toString();

lua - how to convert a UTC time to 12 hr EST time

Background
I get the following date back from the system:
>print(os.date("%d.%m.%y.%c"))
30.11.16.Wed Nov 30 15:39:11 2016
I am trying to figure out how to convert the time so I get back 10:39:11 instead of 15:39:11
So far as a test, I've tried this:
> print(os.date("%I"))
03
and
> print(os.date("%d.%m.%y %I"))
30.11.16 03
>
Question
I guess I don't understand why I'm getting back "03".
What I've Tried
I tried to set the locale information using
os.setlocale('en')
and then retried the os.date command but it's still returning the 03.
Can you tell me what the 03 represents, as well as how I can get back the current time for my time zone (Eastern) and in a 12 hr format?
Thanks.
You are getting 03, because as it states in the Corona docs:
%I: Hour in 12-hour format (01 – 12)
I'd recommend you check what timezone you are getting using %z. Also read that piece of documentation, as all the information you need is there.

How to set time to dd-MMM-yyyy HH:mm:ss in go?

https://play.golang.org/p/82QgBdoI2G
package main
import "fmt"
import "time"
func main() {
fmt.Println(time.Now().Format("01-JAN-2006 15:04:00"))
}
The output should be like if date time today is 2016-03-03 08:00:00 +0000UTC
Output: 03-MAR-2016 08:00:00
Time should be in 24hr format.
Your layout is incorrect, it should show how the reference time is represented in the format you want, where the reference time is Mon Jan 2 15:04:05 -0700 MST 2006.
Your layout should be:
"02-Jan-2006 15:04:05"
Note the 05 for the seconds part. And since you specified the hours as 15, that is 24-hour format. 3 or 03 is for the 12-hour format.
fmt.Println(time.Now().Format("02-Jan-2006 15:04:05"))
For me it prints:
03-Mar-2016 13:03:10
Also note Jan for months, JAN is not recognized. If you want uppercased month, you may use strings.ToUpper():
fmt.Println(strings.ToUpper(time.Now().Format("02-Mar-2006 15:04:05")))
Output:
03-MAR-2016 13:03:10
Also note that on the Go Playground the time is always set to a constant when your application is started (which is 2009-11-10 23:00:00 +0000 UTC).
fmt.Println(time.Now().Format("02-Jan-2006 15:04:05"))
See Time package constants
The reference time used in the layouts is the specific time:
Mon Jan 2 15:04:05 MST 2006
which is Unix time 1136239445. Since MST is GMT-0700, the reference time can be thought of as
01/02 03:04:05PM '06 -0700

C# DateTime.Parse(someString)

I am working on a project and I get the following string representation of time and date, i.e. "00:02:52 APRIL 11, 2013 GMT". When I use the DateTime.Parse() method:
DateTime dt= DateTime.Parse(dateString);
string text = dt.ToString("hh:mm:ss MMM dd, yyyy ").ToUpper();
My output (text) is:
"05:02:52 APR 11, 2013 GMT"
and NOT
"00:02:52 APR 11, 2013 GMT"
I don't get why the hour (HH) has changed to 00 to 05. I traced my code through V.S. many times. All I am doing is truncating the month, APRIL to APR.
Would anyone please give me insight on what I'm doing wrong or missing?
Thanks!
Try this
string dateString = "00:02:52 APRIL 11, 2013 GMT";
DateTime dt = DateTime.Parse(dateString).ToUniversalTime();

Resources