I want to make the date format dd-mm-yyyy, but var ilk, son comes 'invalid date' ?
$('#cmbAnketID').on('change', function (a) {
var firstDate = a.added.element[0].attributes["data-bastar"].value;
var secondDate = a.added.element[0].attributes["data-bittar"].value;
var ilk = moment(firstDate.value, "DD/MM/YYYY").format('YYYY-MM-DD');
var son = moment(secondDate.value, "DD/MM/YYYY").format('YYYY-MM-DD');
$("#ilkTarih").val(ilk);
$("#ikinciTarih").val(son);
});
Related
When I try to get time form table it plus 29 mins and 43 secs constantly
function onEdit(e){
var cal = CalendarApp.getCalendarById("h8ueab6ooel3iv8c7v4nd6bkvg#group.calendar.google.com");
Logger.log(cal)
// var arrayDate, arrayTimeStart, arrayTimeEnd;
var DateStart = new Date();
var DateEnd = new Date();
var table = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var dlinna = table.getLastRow();
var data = table.getRange("A2:E"+dlinna).getValues();
for (var i=data.length-1; i<data.length;i++){
Logger.log(data[i][2]);
}
}
[the given row]
[the weird time]
I want to add time/duration in HH:mm(eg 00:10) to a Date time in format MM-DD-YYYY HH:MM
I have date and time in 2 separate objects so am trying the below
var plannedStartDate = document.getElementById("date1"); //eg 02-12-2020
var plannedStartTime = document.getElementById("plannedStart1"); //eg 09:00
var plannedStartDateTime = moment(plannedStartDate.value + " " + plannedStartTime.value);
var minutes = $("#duration1").text().split(':')[1];
var hours = $("#duration1").text().split(':')[0];
var date = plannedStartDateTime.add(hours, 'hours').add(minutes, 'minutes').format("MM-DD-YYYY HH:mm");
console.log("Final:"+date); //gives invalid date
What am I doing wrong
Check this working sandbox: https://codesandbox.io/s/compassionate-bas-fg1c2
It adds the hours and minutes to the input date and then prints in a given format
var moment = require("moment");
var input = "2020-02-12";
var hoursMinutes = "9:10";
var hours = hoursMinutes.split(":")[0];
var minutes = hoursMinutes.split(":")[1];
var momentInTime = moment(input)
.add(hours, "hours")
.add(minutes, "minutes");
var converted = moment(momentInTime).format("DD-MM-YYYY HH:mm:ss");
console.log(converted);
In separate fields, I collect DisplayDate, DisplayTime, and TimeZone from the user. I want to put those into a moment and output the UTC formatted string to save into a hidden field that gets sent back to the server. I used the below code, but it uses the local timezone, rather than the selected TimeZone I entered. How do I get it to observe selTimeZonesVal?
var startTime = $('#StartTime');
var displayDateVal = $('#DisplayDate').val();
var displayTimeVal = $('#DisplayTime').val();
var selTimeZonesVal = $('#TimeZones').val();
var dtMoment = moment(displayDateVal + ' ' + displayTimeVal).tz(selTimeZonesVal);
var formattedUtc = dtMoment.utc().format('YYYY-MM-DDTHH:mm:ss');
startTime.val(formattedUtc);
The problem was with the date parsing. Somehow, moment was able to parse the date, but it would ignore the timezone if the date wasn't in ISO format.
The fix:
var startTime = $('#StartTimeUtc');
var displayDateVal = $('#DisplayDate').val();
var displayTimeVal = $('#DisplayTime').val();
var selTimeZonesVal = $('#TimeZones').val();
// Massage the date so moment can parse it (moment doesn't like mm/dd/yyyy)
var localDT = new Date(displayDateVal + ' ' + displayTimeVal);
var parseDT = moment(localDT).format('YYYY-MM-DDTHH:mm:ss')
var dtMoment = moment.tz(parseDT, selTimeZonesVal);
var formattedUtc = dtMoment.utc().format('YYYY-MM-DDTHH:mm:ss');
startTime.val(formattedUtc);
I use Full Calendar in my project and I need to get year and month when I click on Prev or Next button.
This is my code, but doesn't work !! It return alway the current date.
$('body').on('click', 'button.fc-prev-button', function () {
var tglCurrent = $('#calendar').fullCalendar('getDate');
var year = moment(tglCurrent).format('YYYY');
var month = moment(tglCurrent).format('MM');
alert('Year is '+year+' Month is '+month);
});
$('body').on('click', 'button.fc-next-button', function () {
var tglCurrent = $('#calendar').fullCalendar('getDate');
var year = moment(tglCurrent).format('YYYY');
var month = moment(tglCurrent).format('MM');
alert('Year is ' + year + ' Month is ' + month);
});
How can I resolve this issue ?
Try to do it in below way
$('body').on('click', 'button.fc-prev-button', function () {
var tglCurrent = $('#calendar').fullCalendar('getDate');
var date = new Date(tglCurrent);
var year = date.getYear();
var month = date.getMonth();
alert('Year is '+year+' Month is '+month);
});
I'm trying to get the current date time in Flex/AIR?
To get the current date time, just create a new Date object with no values into the constructor, like this:
var CurrentDateTime:Date = new Date();
Formatting it depends on how you want to format it; here is one option:
private function CurrentDateTimeString():String
{
var CurrentDateTime:Date = new Date();
var CurrentDF:DateFormatter = new DateFormatter();
CurrentDF.formatString = "MM/DD/YY LL:NN:SS A"
var DateTimeString:String = CurrentDF.format(CurrentDateTime);
return DateTimeString;
}
currentTime = new Date();
From : http://livedocs.adobe.com/flex/3/html/help.html?content=08_Dates_and_times_5.html
and
http://docs.huihoo.com/flex/4/Date.html
private function CurrentDateTimeString():String
{
var CurrentDateTime:Date = new Date();
var DateString:String = CurrentDateTime.getMonth().toString()+ "/"+CurrentDateTime.getDate().toString() +"/"+CurrentDateTime.getFullYear().toString();
var TimeString:String = CurrentDateTime.getHours().toString()+ ":"+ doubleDigitFormat(CurrentDateTime.getMinutes());
var DateTimeString:String = DateString + " " + TimeString;
return DateTimeString;
}
function doubleDigitFormat(num:uint):String
{
if(num < 10) {
return ("0" + num);
}
return num.toString();
}