Payment Date as UTC

I am programming the back end of my site (ASP.Net C # framework 4.0). I listen to the results using my PayPal IPN listener, which will update my internal database.

When the payment is made, I would like to record the date of payment. I had a problem parsing the payment_date parameter, which is provided to me from an IPN message. It looks like this:

args["payment_date"]: 10:23:05 Dec 02, 2013 PST

The following try-parse parameter always returns false:

DateTime paymentDate = DateTime.UtcNow;
DateTime.TryParse(args["payment_date"], out paymentDate);

Does PST mean Pacific Standard Time? I read that some US states that use PST will switch to PDT (Pacific Daylight Time) at some point in the year.

In my database, I would like to store all DateTimes as UTC. Is there any way I can ask PayPal to give me the payment date in UTC? Or do I need to write my own parser? If so, is there anything else I should watch for except switching from PST to PDT?

You might think that I just need to use my own server time to record the payment date, but I just thought it would be better to use the date given by PayPal in the actual IPN message.

+4
source share
2 answers

Just specify a custom format DateTimethat matches what PayPal gives and pass it to a method TryParseor TryParseExact:

DateTime paymentDate = DateTime.UtcNow;
string format = "hh:mm:ss MMM dd, yyyy";
DateTime.TryParseExact(args["payment_date"], out paymentDate, format, CultureInfo.InvariantCulture);

: http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx

.NET, , : Parse DateTime PST/CEST/UTC/ ..

+1

:

HH HW: MM: SS DD Mmm (.) YYYY PST/PDT # UTC DateTime?

HH: MM: SS DD Mmm (.) YYYY PST/PDT .

+1

All Articles