[Solved] DateTime Format user entries


To get the total seconds. Try the following.

        var testString = "2Y 4M 3D";
        var splitString = testString.Split(' ');
        var year = int.Parse(splitString[0][0].ToString(CultureInfo.InvariantCulture));
        var month = int.Parse(splitString[1][0].ToString(CultureInfo.InvariantCulture));
        var day = int.Parse(splitString[2][0].ToString(CultureInfo.InvariantCulture));
        var totalSeconds = (DateTime.Now.AddYears(year).AddMonths(month).AddDays(day) - DateTime.Now).TotalSeconds;

Heres a Demo

solved DateTime Format user entries