2
I’m developing a program where there’s a 15-day trial period.
When the user registers an account in the application, it takes the internet date and registers the current date and the date of the end of the test period, which is 15 days after the current date, in the database.
data_registro | data_vencimento 01/06/2017 | 16/06/2017
How do I compare the date provided by this code:
public static DateTime DataAtual()
{
var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
var response = myHttpWebRequest.GetResponse();
string todaysDates = response.Headers["date"];
return DateTime.ParseExact(todaysDates,
"ddd, dd MMM yyyy HH:mm:ss 'GMT'",
CultureInfo.InvariantCulture.DateTimeFormat,
DateTimeStyles.AssumeUniversal);
}
The return of the above code is done by this code: DataAtual().ToShortDateString();
resulting in: 01/06/2017
With the database, in the field: data_vencimento
to validate whether or not the testing period is over?
With string it works?
– Marlon Pereira
No. Nor would I have why.
– Jéf Bueno
But in the bank the date is in string
– Marlon Pereira
Then convert to
DateTime
.– Jéf Bueno