I have a date variable (coming from an external source):
var date = '28/04/2017';
var time = '19:28';
It is possible to format these variables with moment.js (or without?) to variout formats?
Example: 04.28 19:28, 2017.04.28 19:28 or even Today at 19:28 (with moment().calendar();)
I tried
moment(date+' '+time).format('MM.DD.YYYY');
...but I am getting "Invalid date" error.
SearchDate = moment(new Date(), “DD/MM/YYYY”);
Just like this: moment(). subtract(1, 'days') . It will give you the previous day with the same exact current time that is on your local pc.
You're using moment(String)
method, but you're not passing a Supported
format that it expects to parse.
You should use moment(String, String)
, where the first String is the input date string, and second is the format of your input date String.
Try this:
moment(date+' '+time,'DD/MM/YYYY HH:mm').format('MM.DD.YYYY');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With