L
L
LebedevStr2017-10-04 02:36:34
Programming
LebedevStr, 2017-10-04 02:36:34

How to change date format in C#?

using System;
using System.Collections.Generic;
using System.Text;
using DynamicPluginData;

namespace DatacolDynamicPluginNS
{
    public class DynamicPluginClass
    {
        public static string processDataFieldValue(string s, ItemInfo itemInfo, GlobalInfo globalInfo)
        {
            return s;
        }
    }
}

s = 29.10.2017
How to s = 2017-10-29
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2017-10-04
@kttotto

var date = DateTime.Now;
Console.WriteLine(date.ToString("yyyy-MM-dd"));

Details about date formatting
But syou have type string, so you must first cast it to DateTime:
DateTime date;
var result = DateTime.TryParse(s, out date);
if(result)
{
    var dateFormat = date.ToString("нужный формат");
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question