daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var date = new Date(call.Timestamp);
  2. date.toLocaleString()
  3.    
  4. date.toLocaleDateString() + ' ' + date.toLocaleTimeString()
  5.    
  6. var date = new Date();
  7. var d = [date.getDate(), date.getMonth()+1, date.getFullYear()];
  8. var t = [date.getHours(), date.getMinutes(), date.getSeconds()];
  9. var dateStr = d.join("/") + " " + t.join(":");
  10.    
  11. /*
  12.  * Date Format 1.2.3
  13.  * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
  14.  * MIT license
  15.  *
  16.  * Includes enhancements by Scott Trenda <scott.trenda.net>
  17.  * and Kris Kowal <cixar.com/~kris.kowal/>
  18.  *
  19.  * Accepts a date, a mask, or a date and a mask.
  20.  * Returns a formatted version of the given date.
  21.  * The date defaults to the current date/time.
  22.  * The mask defaults to dateFormat.masks.default.
  23.  */
  24.  
  25. var dateFormat = function () {
  26.     var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])1?|[LloSZ]|"[^"]*"|'[^']*'/g,
  27.         timezone = /b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]d{4})?)b/g,
  28.         timezoneClip = /[^-+dA-Z]/g,
  29.         pad = function (val, len) {
  30.             val = String(val);
  31.             len = len || 2;
  32.             while (val.length < len) val = "0" + val;
  33.             return val;
  34.         };
  35.  
  36.     // Regexes and supporting functions are cached through closure
  37.     return function (date, mask, utc) {
  38.         var dF = dateFormat;
  39.  
  40.         // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
  41.         if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/d/.test(date)) {
  42.             mask = date;
  43.             date = undefined;
  44.         }
  45.  
  46.         // Passing date through Date applies Date.parse, if necessary
  47.         date = date ? new Date(date) : new Date;
  48.         if (isNaN(date)) throw SyntaxError("invalid date");
  49.  
  50.         mask = String(dF.masks[mask] || mask || dF.masks["default"]);
  51.  
  52.         // Allow setting the utc argument via the mask
  53.         if (mask.slice(0, 4) == "UTC:") {
  54.             mask = mask.slice(4);
  55.             utc = true;
  56.         }
  57.  
  58.         var _ = utc ? "getUTC" : "get",
  59.             d = date[_ + "Date"](),
  60.             D = date[_ + "Day"](),
  61.             m = date[_ + "Month"](),
  62.             y = date[_ + "FullYear"](),
  63.             H = date[_ + "Hours"](),
  64.             M = date[_ + "Minutes"](),
  65.             s = date[_ + "Seconds"](),
  66.             L = date[_ + "Milliseconds"](),
  67.             o = utc ? 0 : date.getTimezoneOffset(),
  68.             flags = {
  69.                 d:    d,
  70.                 dd:   pad(d),
  71.                 ddd:  dF.i18n.dayNames[D],
  72.                 dddd: dF.i18n.dayNames[D + 7],
  73.                 m:    m + 1,
  74.                 mm:   pad(m + 1),
  75.                 mmm:  dF.i18n.monthNames[m],
  76.                 mmmm: dF.i18n.monthNames[m + 12],
  77.                 yy:   String(y).slice(2),
  78.                 yyyy: y,
  79.                 h:    H % 12 || 12,
  80.                 hh:   pad(H % 12 || 12),
  81.                 H:    H,
  82.                 HH:   pad(H),
  83.                 M:    M,
  84.                 MM:   pad(M),
  85.                 s:    s,
  86.                 ss:   pad(s),
  87.                 l:    pad(L, 3),
  88.                 L:    pad(L > 99 ? Math.round(L / 10) : L),
  89.                 t:    H < 12 ? "a"  : "p",
  90.                 tt:   H < 12 ? "am" : "pm",
  91.                 T:    H < 12 ? "A"  : "P",
  92.                 TT:   H < 12 ? "AM" : "PM",
  93.                 Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
  94.                 o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
  95.                 S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
  96.             };
  97.  
  98.         return mask.replace(token, function ($0) {
  99.             return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
  100.         });
  101.     };
  102. }();
  103.  
  104. // Some common format strings
  105. dateFormat.masks = {
  106.     "default":      "ddd mmm dd yyyy HH:MM:ss",
  107.     shortDate:      "m/d/yy",
  108.     mediumDate:     "mmm d, yyyy",
  109.     longDate:       "mmmm d, yyyy",
  110.     fullDate:       "dddd, mmmm d, yyyy",
  111.     shortTime:      "h:MM TT",
  112.     mediumTime:     "h:MM:ss TT",
  113.     longTime:       "h:MM:ss TT Z",
  114.     isoDate:        "yyyy-mm-dd",
  115.     isoTime:        "HH:MM:ss",
  116.     isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
  117.     isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
  118. };
  119.  
  120. // Internationalization strings
  121. dateFormat.i18n = {
  122.     dayNames: [
  123.         "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
  124.         "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
  125.     ],
  126.     monthNames: [
  127.         "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
  128.         "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  129.     ]
  130. };
  131.  
  132. // For convenience...
  133. Date.prototype.format = function (mask, utc) {
  134.     return dateFormat(this, mask, utc);
  135. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top