Pchp.Library.DateTimeUtils.UnixTimeStampToUtc C# (CSharp) Method

UnixTimeStampToUtc() static private method

Converts UNIX timestamp (number of seconds from 1.1.1970) to System_DateTime.
static private UnixTimeStampToUtc ( int timestamp ) : System.DateTime
timestamp int UNIX timestamp
return System.DateTime
        internal static System_DateTime UnixTimeStampToUtc(int timestamp)
        {
            return UtcStartOfUnixEpoch + TimeSpan.FromSeconds(timestamp);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Returns a part of a specified timestamp.
        /// </summary>
        /// <param name="format">Format definition for output.</param>
        /// <param name="timestamp">Nuber of seconds since 1970 specifying a date.</param>
        /// <returns>Part of the date, e.g. month or hours.</returns>
        public static int idate(Context ctx, string format, int timestamp)
        {
            if (format == null || format.Length != 1)
            {
                //PhpException.InvalidArgument("format");
                throw new ArgumentException();
            }

            return(GetDatePart(format[0], DateTimeUtils.UnixTimeStampToUtc(timestamp), PhpTimeZone.GetCurrentTimeZone(ctx)));
        }
All Usage Examples Of Pchp.Library.DateTimeUtils::UnixTimeStampToUtc