Hi.
So here is my situation, When I have a player create a ticket on my PvX ticket to request a change it stored a DateTime as a double, later when an admin accepts it a log ticket is created for records and everything is saved and a new DateTime is also saved to store when it was accepted.
I would like to know how to convert this double into an actual string format in C# something along the lines of hh/mm dd/MM
I would prefer the Date and Time to be based on the server to simplify things.
Any help would be great.
Regards
Alpha
Solved Storing time and converting to hh/mm dd/mm?
Discussion in 'Rust Development' started by Alphawar, Aug 4, 2016.
-
Why are you storing a DateTime as a double?
What does the double value contain? Seconds since 1970? -
Correct Seconds since 1970.
Also I'm storing it as a double as that's what I have seen on other scripts.Last edited by a moderator: Aug 4, 2016 -
where "d" is your double and "your format string" is your formatting syntax as described by Custom Date and Time Format Strings.Code:
var s = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(d).ToString("your format string"); -
Thanks for that.
-
You already got the answer you were after but if you wanted to store datetime in a MySQL database you could use
this returns the dt as UTC which i've found is the best way to store it as you can then convert it to any timezone for display purposes. How to convert DateTime in Specific timezone?Code:string GetMySQLDateTimeUTC() { return DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm"); } -
Thanks for that, usefull tip as I was wanting to look at making a ticket system onto a database. <--Bad spelling yes, Tired I am
