Guest User

Untitled

a guest
Feb 4th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. public static string DateCalc(int mode) {
  2.             string DTmonth;
  3.             string DTday;
  4.             string DThour;
  5.             string DTmin;
  6.             string DTsec;
  7.             string Date;
  8.             if (DateTime.Now.Month.ToString().Length == 1)
  9.             {
  10.                 DTmonth = "0" + DateTime.Now.Month;
  11.             }
  12.             else { DTmonth = DateTime.Now.Month.ToString(); }
  13.             if (DateTime.Now.Day.ToString().Length == 1)
  14.             {
  15.                 DTday = "0" + DateTime.Now.Day.ToString();
  16.             }
  17.             else { DTday = DateTime.Now.Day.ToString(); }
  18.             if (DateTime.Now.Hour.ToString().Length == 1)
  19.             {
  20.                 DThour = "0" + DateTime.Now.Hour.ToString();
  21.             }
  22.             else { DThour = DateTime.Now.Hour.ToString(); }
  23.             if (DateTime.Now.Minute.ToString().Length == 1)
  24.             {
  25.                 DTmin = "0" + DateTime.Now.Minute.ToString();
  26.             }
  27.             else { DTmin = DateTime.Now.Minute.ToString(); }
  28.             if (DateTime.Now.Second.ToString().Length == 1)
  29.             {
  30.                 DTsec = "0" + DateTime.Now.Second.ToString();
  31.             }
  32.             else { DTsec = DateTime.Now.Second.ToString(); }
  33.             if (mode == 1)
  34.             {
  35.                 Date = DateTime.Now.Year + "." + DTmonth + "." + DTday + " " + DThour + ":" + DTmin + ":" + DTsec;
  36.             }
  37.             else { Date = DateTime.Now.Year + "." + DTmonth + "." + DTday + " " + DThour + "-" + DTmin + "-" + DTsec; }
  38.             return Date;
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment