Get Date from String by format - CSharp System

CSharp examples for System:DateTime Format

Description

Get Date from String by format

Demo Code


using System.Web;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Extensions;
using System.Web.Mvc;
using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System;//from w  w w  .j a  va  2  s .c o  m

public class Main{
        public static DateTime GetDate(this string date, string format = "MM/dd/yyyy HH:mm")
        {
            if (format.IsNotNullOrEmpty())
            {
                if (date.IndexOf("/") != -1)
                {
                    //date.Split("/")
                }
                else if (date.IndexOf("-") != -1)
                {

                }

            }
            return new DateTime();
        }
        /// <summary>
        /// Determines whether [is not null or empty] [the specified s].
        /// </summary>
        /// <param name="s">The s.</param>
        /// <returns></returns>
        public static bool IsNotNullOrEmpty(this string s)
        {
            if (s == null) return false;
            if (s.Trim() == string.Empty) return false;
            return true;
        }
}

Related Tutorials