Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Convert JS date time to MySQL datetime

var date;
date = new Date();
date = date.getUTCFullYear() + '-' +
    ('00' + (date.getUTCMonth()+1)).slice(-2) + '-' +
    ('00' + date.getUTCDate()).slice(-2) + ' ' + 
    ('00' + date.getUTCHours()).slice(-2) + ':' + 
    ('00' + date.getUTCMinutes()).slice(-2) + ':' + 
    ('00' + date.getUTCSeconds()).slice(-2);
console.log(date);
Comment

PREVIOUS NEXT
Code Example
Javascript :: js remove last char of string 
Javascript :: logic operators in js 
Javascript :: children javascript 
Javascript :: js read external json file js 
Javascript :: jason in javascript 
Javascript :: get key for value javascript 
Javascript :: javascript add to object 
Javascript :: react build blank page 
Javascript :: js basic user class 
Javascript :: vitejs env 
Javascript :: javascript array column 
Javascript :: d3 not reading json 
Javascript :: json loop in js 
Javascript :: express json body 
Javascript :: mongo connect npm 
Javascript :: array flat 
Javascript :: how to code javascript 
Javascript :: anchor click event angular refresh page 
Javascript :: add new database mongodb 
Javascript :: without refresh update url in js 
Javascript :: substring methods example 
Javascript :: method chaining in javascript 
Javascript :: counter with react hooks 
Javascript :: Get the current tab 
Javascript :: firebase.apps.length 
Javascript :: javascript divide string into two parts 
Javascript :: cors blocking communication 
Javascript :: perform a function on each element of array javascript 
Javascript :: An invalid form control with ... is not focusable. 
Javascript :: jest tranform image 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =