$scope.calcTime = function(date){
var dateFormat = 'DD/MM/YYYY HH:mm:ss';
var end = moment(date);
var now = moment();
var difference = moment(endDate,dateFormat).diff(moment(currentDate,dateFormat));
var duration = moment.duration(timeDIff);
var formatDuration = timeDuration.format("d дня hh часов mm минут ss секунд");
console.log(formatDuration);
return formatDuration;
}
<div>
<div ng-repeat="item in Info">
<h3>{{item.name}}</h3>
<p>До окончания:<br />{{calcTime(item.date)}}</p>
</div>
</div>
var fs = require('fs');
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var html = fs.readFileSync('./index.html');
app.use(bodyParser.urlencoded({}));
app.get('/', function(req, res) {
res.writeHeader(200, {"Content-Type": "text/html"});
res.end(html);
});
app.post('/myaction', function(req, res){
var word = req.body.name;
var event = {
title: word,
date: "20.20.20"
};
var str = JSON.stringify(event);
fs.writeFile('test.txt', str, function(err) {
if(err) console.error(err);
else res.end("Success");
});
});
app.listen(3000);
$(document).on('click', '.num', function () {
console.log(123);
});
<p class="tel">8-800-</p>
<p class="name">ИМЯ</p>
<a href="#" class="send">send</a>
$('html').on('click','.send',function() {
var a = $('.tel').text();
var b = $('.name').text();
$.ajax({
type: 'POST',
url: 'URL',
data: {
'tel': a,
'name': b
},
cache: false,
dataType: 'json',
timeout: 15000,
success: function(result) {
// тут что-то делаем с ответом
},
error: function() {
// выводим ошибку
}
});
});
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var imageObj1 = new Image();
var imageObj2 = new Image();
imageObj1.src = "1.png"
imageObj1.onload = function() {
ctx.drawImage(imageObj1, 0, 0, 328, 526);
imageObj2.src = "2.png";
imageObj2.onload = function() {
ctx.drawImage(imageObj2, 15, 85, 300, 300);
var img = c.toDataURL("image/png");
document.write('<img src="' + img + '" width="328" height="526"/>');
}
};