1

I have a input in form like this:

<input  id="sendDate" type="date" ng-model="aN.formData.sendDate" title="Formato inválido: introducir el número de segundos" required>

When i submit the form i have the output in console, this ouput: Thu Oct 29 2015 00:00:00 GMT+0100 (CET)

How I can convert this format to milliseconds when i send the form?

I've been reading other posts and have not been of much help.

thanks!

2

4 Answers 4

10
new Date('Thu Oct 29 2015 00:00:00 GMT+0100 (CET)').getTime()
Sign up to request clarification or add additional context in comments.

Comments

2

That's a date - not a period of time - so you can't convert that to milliseconds ...

Do you want to convert it to a unix timestamp ? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime

Or do you want to get the milliseconds from a that time ?

var today = new Date();
var milliseconds = today.getMilliseconds();

example above from - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds

Comments

1
$scope.aN.formData.sendDate.getTime();

Comments

0

You could try moment.js (http://momentjs.com/docs). There is an "duration" feature to get milliseconds, but there is a bunch of alternative ones you wrap a date into moment.js

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.