Forum BigDB Date and Time Need Help

Discussion and help relating to the PlayerIO database solution, BigDB.

Date and Time Need Help

Postby TD » March 3rd, 2016, 2:06 pm

hey im making a ban system were u can ban users for 1 day or 3 days, and i want it to show the count down in banned screen days, hours, mins

Anyone can help me out?...
TD
 
Posts: 11
Joined: February 3rd, 2016, 3:56 pm

Re: Date and Time Need Help

Postby robscherer123 » March 3rd, 2016, 3:14 pm

You would use the DateTime class in C# to store the original date that they were banned. C# then has a TimeSpan class that you can use with DateTime to calculate the number of remaining time until they are unbanned.


Code: Select all

TimeSpan timeSpan = DateTime.Now - banDate;

if(timeSpan.totalDays >= 3){
     //Unban the user here.
}

robscherer123
Paid Member
 
Posts: 313
Joined: December 12th, 2012, 8:46 pm

Re: Date and Time Need Help

Postby TD » March 3rd, 2016, 6:02 pm

Yes but when i did and broadcasted the Hours left it made the hours 3.45742684268 why does it have a decimal point + numbers i only want it to show the hours not hours and then some Lol
TD
 
Posts: 11
Joined: February 3rd, 2016, 3:56 pm

Re: Date and Time Need Help

Postby Henrik » March 4th, 2016, 10:40 pm

Because TotalHours is a double that has decimals. If you don't want to display those, you can either cast the number to an int, or you can format it when you print it.

https://msdn.microsoft.com/en-us/librar ... 10%29.aspx
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Date and Time Need Help

Postby TD » March 5th, 2016, 3:31 am

Thanks dude !
TD
 
Posts: 11
Joined: February 3rd, 2016, 3:56 pm


Return to BigDB



cron