Date + time by label in angular2
I am trying to learn angular2 + and I want to make a GoogleCalendar app like a scheduler. After a lot of research, I decided to use PrimeNG. Calendar output format
2016-01-16T16:00:00
which seems big and complete. But the api I want to use is using timeStamp ...
I tried to create a Javascript function that parses the date format:
function toTimestamp(strDate){
var datum = Date.parse(strDate);
return datum/1000;
}
alert(toTimestamp('02/13/2009 23:31:30'));
But my problem is that I cannot use PrimeNG format ...
Does anyone know how I can interact with the format I need to convert to a timestamp?
otherwise, did anyone know how I can get this date format (2016-01-16T16: 00: 00) into a timestamp using angular2 +? Thank you so much!!
source to share
You are on the right track as far as I can see. I suggest you use the Javascript date https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Date to create a new date instead of trying to parse the original primeng output.
new Date()
can be used with many parameters. If new Date(datestring)
doesn't work as I expected, use split to split your output string into variables that you can use to fill
new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);
It might be a little sweat work, but it has to do the trick.
This is my first answer, so mods are gentle with my formatting.
source to share