PetroGromovo
4 months ago
549
3
Vue

How correctly convert date time to moment format?

Posted 4 months ago by PetroGromovo

Hello, Using vuejs 2.6 I have a function to which I sent datetime in string format like : 2019-06-03 16:53:29 , convert it to moment format and next I converto to other string format, like:

        momentDatetime(datetime, datetime_format, default_val) {

            let dt= datetime
            if (typeof datetime == "string") {
                if (datetime_format == "") return '';

                dt = Vue.moment(String(datetime));

            } // if (typeof datetime == "string") {

That works if datetime is string, now I want to send (current) datetime, like :

            item.created_at= this.momentDatetime( moment( new Date() ), this.settings_js_moment_datetime_format )

I failed with line above. How correctly convert date time to moment format ?

Please sign in or create an account to participate in this conversation.