How to use date-and-time - 10 common examples

To help you get started, we’ve selected a few date-and-time examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / MentalHealthPlatform / server / path.js View on Github external
// Create new chat
		var chatObj = {};
		chatObj.chatTitle = obj.chatTitle;
		chatObj.user_id = obj.username;
		chatObj.topic_id = obj.topicId.toString();
		chatObj.PostedDate = (new Date()).toString();
		chatObj.numberofviews = 0;
		chatObj.numberofreplies = 0;
		chatObj.desc = obj.chatDescription;

		// Create new message
		var msgObj = {};
		msgObj.messageBody = obj.chatDescription;
		msgObj.username = obj.username;
		msgObj.date = date.format(new Date(), "MM/DD/YYYY");

		dbo.collection(chatsColl).countDocuments().then((count) => {
			
			// Insert chat to db
			dbo.collection(chatsColl).insertOne(chatObj, function(insertChatErr, insertChatRes) {
				if (insertChatErr) throw insertChatErr;
				// console.log("Chat inserted");
				// Insert message to db
				dbo.collection(msgColl).insertOne(msgObj, function(insertMsgErr, insertMsgRes) {
					db.close();
					postRes.json({
						statusMessage : 1,
						chatId: insertChatRes.ops[0]._id
					});
					// console.log("chat responding with messages");
				});
github kpi-wdc / dj / wdc_libs / parsers / ch-ftp / aggregate.js View on Github external
result.forEach(function(d,index){
		var r = {}
		r.metadata =clone(dataset.metadata);
		r.validation = clone(dataset.validation);
		r.dictionary = (index == 0) ? dataset.dictionary : [];

		r.metadata.dataset.periodicity = d.periodicity;
		r.metadata.dataset.commit.note = "Upload from SSE ChNPP source at "+date.format(new Date(),"YYYY/MM/DD hh:mm:ss");
		r.metadata.dataset.id +="_"+d.datasetId;
		r.metadata.dataset.ext ="( "+d.datasetLabel+" )";
		r.data = d.data;

		for(var dim in r.metadata.dimension){
			r.metadata.dimension[dim].values = getValueList(dim,r.data)
		}	

		r.metadata.dimension.time.format = valueLabelFormat[r.metadata.dataset.periodicity]

		// if(r.metadata.dimension[dim].scale == "ordinal"){
	 //    	r.metadata.dimension[dim].range = [
	 //    		date.format(r.metadata.dimension[dim].values[0],valueLabelFormat[d.periodicity]),
	 //    		date.format(r.metadata.dimension[dim].values[r.metadata.dimension[dim].values.length-1],valueLabelFormat[d.periodicity])
	 //    	] 
	 //    } 
github Wikiki / bulma-calendar / src / js / index.js View on Github external
set maxDate(date = undefined) {
    this.datePicker.maxDate = dateUtils.parse(date, this.dateFormat);
    return this;
  }
  // Get maxDate
github yueyericardo / WeiNote / routes / wiki.js View on Github external
router.post('/create', checkLogin, function (req, res, next) {
  const author = req.session.user._id;
  var title = req.fields.title;
  var content = req.fields.content;
  var tag = req.fields.tag;
  var top = (req.fields.is_top === 'true')
  var hide = (req.fields.is_hide === 'true')
  var postdate = req.fields.postdate;
  var mydate = date.parse(postdate, 'YYYY-MM-DD');
  var postdate = date.format(mydate, 'MMM DD YYYY');
  var mydate = date.format(mydate, 'YYYY-MM-DD');

  if (req.fields.new_tag != '') {
  	tag = req.fields.new_tag;
  	console.log("there are new tags");
  }
  let post = {
    author: author,
    title: title,
    content: content,
    postdate: postdate,
    mydate: mydate,
    tag: tag,
    top: top,
    hide: hide,
  }
github kpi-wdc / dj / dj-libs / script / impl / javascript / eval.js View on Github external
date: function(value,format){
                           format = format || "YYYY MM DD";
                           return dt.format(value,format)
                        }
                    },
github kpi-wdc / dj / wdc_libs / parsers / ch-ftp / aggregate.js View on Github external
var truncAndShiftDate = function(d,period){
		var vtp = valueTimePattern[period];
		return shift[period](date.parse(date.format(new Date(d),vtp),vtp))
	}
github kpi-wdc / dj / api / controllers / IOController.js View on Github external
}
      var response = {
        log: logger.success("total: "+responseList.length+" from "+((obj) ? obj.length:"0")).get(),
        data: {
          source: req.host,
          file: req.host+"_export_Dataset_"+date.format(new Date(),"YYYY_MM_DD_hh_mm_ss")+".json",
          type: mime.lookup("json"),
          downloadedAt: new Date(),
          collection:"Dataset",
          list:responseList
        }
      }
      logger.clear();
      res.setHeader('Content-type', mime.lookup("json"));
      res.setHeader('Content-disposition', 'attachment; filename=' + req.host+"_export_Dataset_"+date.format(new Date(),"YYYY_MM_DD_hh_mm_ss")+".json");
      res.setHeader("X-Filename", req.host+"_export_Dataset_"+date.format(new Date(),"YYYY_MM_DD_hh_mm_ss")+".json");
      res.setHeader("Access-Control-Expose-Header","Content-disposition, Content-type, X-Filename");
      return res.send(response);
    }, function (err) {
      var response = {
github binder-project / binder-web / site / status.js View on Github external
var label = document.createElement('div')
    label.innerHTML = entry.status
    if (entry.status == 'running') {
      css(status, extend(style.status, {backgroundColor: theme.GREEN}))
      css(label, extend(style.label, {color: theme.GREEN}))
    }
    if (entry.status == 'down') {
      css(status, extend(style.status, {backgroundColor: theme.RED}))
      css(label, extend(style.label, {color: theme.RED}))
    }
    row.appendChild(name)
    row.appendChild(status)
    if (entry.timestamp) {
      var timestamp = document.createElement('div')
      var ts = new Date(entry.timestamp)
      var datestring = datetime.format(ts, 'MM/DD/YY HH:mm:ss')
      timestamp.innerHTML = datestring
      css(timestamp, style.timestamp)
      row.appendChild(timestamp)
    }
    if (!ismobile) row.appendChild(label)
    container.appendChild(row)
  })
}
github ink-components / ink-components / src / InkSimple.js View on Github external
render() {

        let d = this.date;
        if(date.isValid(this.date, SERVER_DATE_FORMAT)){
            d = date.format(date.parse(this.date, SERVER_DATE_FORMAT), 'MMMM DD, YYYY');
        }

        let authors = this.authors
        if(typeof(authors) == "string"){
            authors = JSON.parse(authors);
        }

        return html`
            <style>
                .byline{
                    margin-right: -10px;
                    margin-top: -20px;
                    color:#9A9A9A;
                    min-height: 50px;
                }
                .date{</style>
github microsoft / MentalHealthPlatform / client / src / util / Helpers.ts View on Github external
export function getShortenedTimeAndDate(date: Date) {
    return dateAndTime.format(date, "h:mm A MM/DD/YYYY").replace("p.m.", "pm").replace("a.m.", "am");
}