Page 1 of 2
Format "date" data type from database
Posted: Tue Feb 03, 2015 12:37 pm
by Rui Song Chong
Hi,
I am trying to change the date retrieved from database and format it into "dd/mm/yyyy".
I tried input this ("$.datepicker.formatDate('dd/mm/yy', new Date(value));" and "return $.format.date(value, "dd MMMM, yyyy");" into the js in the mapping, however it does not work.
Is any problem with my coding? How can I accomplish this?
Format "date" data type from database
Posted: Tue Feb 03, 2015 2:04 pm
by Evgene Karachevtsev
Rui,
Please add next for label_date in the js:
prevar date = value.split(" ");
var date_parts = date.split("-");
return date_parts[2]+"/"+date_parts[1]+"/"+date_parts[0]/pre
Format "date" data type from database
Posted: Wed Feb 04, 2015 3:13 am
by Rui Song Chong
Hi,
I tried to put it in into the js just like what you told me to, but I still get the same result.
Format "date" data type from database
Posted: Thu Feb 05, 2015 3:43 pm
by Ihor Didevych
Hello,
1) in DB event_date column has correct value
2) Could you add console.log(date_parts[2]+"/"+date_parts[1]+"/"+date_parts[0]);
before return, and open console while testing?
It is looks like you have a cache problem.
Format "date" data type from database
Posted: Thu Feb 05, 2015 6:49 pm
by Rui Song Chong
Hi,
This is the error I get, please advise thanks!
Format "date" data type from database
Posted: Fri Feb 06, 2015 5:44 am
by Yurii Orishchuk
Hi Rui,
".split" functionality return an array.
But you use it like string.
See details here: http://prntscr.com/61nf4c/direct
Regards.
Format "date" data type from database
Posted: Fri Feb 06, 2015 6:49 am
by Rui Song Chong
Hi,
Thank you so much, I manage to display what I want.
For those who need it, this is a way to achieve it:
"var date = value.split(" ");
var date1 = date[0];
var date_parts = date1.split("-");
return date_parts[2]+"/"+date_parts[1]+"/"+date_parts[0];".
Format "date" data type from database
Posted: Fri Feb 06, 2015 7:00 am
by Evgene Karachevtsev
Hello Rui,
Thank you for the update, glad it works!
Format "date" data type from database
Posted: Sun Mar 22, 2015 2:59 am
by Ilya Nikitin
Hello.
Thank you for the tips on date formatting.
How to add to beside date time in following format dd/mm/yyyy - hh:mm
Thank you in advance.
Format "date" data type from database
Posted: Sun Mar 22, 2015 1:51 pm
by Egor Kotov6832188
Hello Ilya,
date[1] - has time frame of datetime.
return date_parts[2]+"/"+date_parts[1]+"/"+date_parts[0] + " - " + date[1];