Returns current datetime in common format. - CSharp System

CSharp examples for System:DateTime Format

Description

Returns current datetime in common format.

Demo Code

/********************************************************************
 *  FulcrumWeb RAD Framework - Fulcrum of your business             *
 *  Copyright (c) 2002-2010 FulcrumWeb, ALL RIGHTS RESERVED         *
 *                                                                  *
 *  THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED      *
 *  FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE        *
 *  COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE       *
 *  AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT  *
 *  AND PERMISSION FROM FULCRUMWEB. CONSULT THE END USER LICENSE    *
 *  AGREEMENT FOR INFORMATION ON ADDITIONAL RESTRICTIONS.           *
 ********************************************************************/
using System.Globalization;
using System;/*from www . j a va2s.  c  om*/

public class Main{
        //-------------------------------------------------------------------------
    /// <summary>
    /// Returns current date/time in common format.
    /// </summary>
    /// <returns>current date/time in common format</returns>
    static public string NowAsString()
    {
      return DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
    }
}

Related Tutorials