This question already has answers here:
Parsing a string to a date in JavaScript
(35 answers)
Closed 4 years ago.
I have string value '05-Jan-18' to be converted to date format using javascript. can someone help me on this.
You can just do:
var d = new Date("05-Jan-18")
Yeah '05-Jan-18' does not work everywhere. However
new Date("05-Jan-18".replace(new RegExp('-', 'g'), ' '))
should work
Related
This question already has answers here:
Parsing ISO 8601 date in Javascript
(5 answers)
Closed last year.
Time format i have is 2022-02-16T12:33:44Z
How can is make this
2022-02-16
12:33
including br tag.
what i tried was date.split("T") but don't know what to do next
const str = "2022-02-16T12:33:44Z"
str.split("T")[0]
str.split("T")[1].slice(0,-4)
Output
2022-02-16
12:33
This question already has answers here:
How to convert string into float in JavaScript?
(9 answers)
Closed 1 year ago.
So I'm getting this string '41803.96000000'
what i want to do is convert this to a number and it should be in the
right format such as this example '41.96000000'
for anyone wondering this is the current bitcoin price which I'm getting from a binance WebSocket
You can use parseFloat('41803.96000000')
This question already has answers here:
Convert dd-mm-yyyy string to date
(15 answers)
Parsing a string to a date in JavaScript
(35 answers)
Closed 2 years ago.
Trying converting the value vr 27.03.2020 to a Date object
<script>
let date = new Date("vr 27.03.2020");
console.log(date);
</script>
Result:
Invalid Date
What is the best way convert the value to a Date object?
PS: vr is abbreviation from dutch vrijdag (=friday)
This question already has answers here:
Convert UTC Epoch to local date
(16 answers)
Closed 5 years ago.
Currently I am getting date as string 1524801600000. I want to convert it as new Date(2018, 4, 27).
How can I do that using jQuery or JavaScript?
Just pass it to Date Constructor.
(+) Unary operator. Attempts to convert the operand to a number, if it is not already. more details here
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators
var temp="1524801600000";
var p=new Date(+temp)
console.log(p)
This question already has answers here:
How do I format a date in JavaScript?
(68 answers)
Closed 6 years ago.
I need to get the current date and time javascript in the following format
YYYY-MM-DD HH:MM:SS
But cannot work out how to do it.
var d = new Date();
timesheetGrid.cellById(rId,15).setValue(d);
This is where I am using the data.
Any help would be greatly appreciated.
How about simply:
d.toISOString().replace('T', ' ').replace(/\..*$/, '');
Take the ISO string, replace the "T" with a space, and trim off the milliseconds.