A few questions on a database

Hi, I have built a database for reviews (see image below), which I imported from a csv file. Some things are not turning out the way I would like. It would be great if I could get some help on it.
The following are the issues:

  1. Is there a simple way to show a Date and Time field type just as a Date? Having just dates as input it looks silly when it shows “Fri Aug 21 2015 00:00:00 GMT-0430 (-0430)” when I only need Aug 21, 2015.

  2. Apparently there are unknown characters that look fine in csv but not in the database, like " or ç (see image). They all turn into a question mark. Is there a way to avoid this.

  3. …and Wix support shows that: to delete an item from a collection, right-click the row number, and then select delete. I’m unable to delete a row. There’s proabably a really easy way but I can’t figure it out. I’m using a MacBook and tried Ctr click, Cmd click, etc. but nothing happens.

Your help on this is very much appreciated!

Hi Linda,

Glad to see you’re getting into WixCode. Let me see if I can help you out a bit…

  1. Here’s a simple date formatting routine you can use. Modify it to your needs.
function formatDate(date) {
  const monthNames = [
    "Jan", "Feb", "Mar",
    "Apr", "May", "Jun", "Jul",
    "Aug", "Sep", "Oct",
    "Nov", "Dec"
  ];

  let day = date.getDate();
  let monthIndex = date.getMonth();
  let year = date.getFullYear();

  return monthNames[monthIndex] + '. ' + day + ', ' + year;
}

Here’s an example of how to use it:

let today = new Date();
let str = formatDate(today);
console.log(str);

In the Developer console you will see this output:
Jan. 7, 2018

  1. You might be having a problem converting from the character coding in your CSV to the coding used for your site. I believe the site uses UTF-8 - although this might vary based on settings/location/etc.

  2. On the Macbook Pro, the “right click” is the “Secondary click”. As the screen shot from my Mac, you can see it’s defined as “tap with two fingers”.

I hope this helps.

Have fun and come back if you’re still having problems.

Yisrael

Hi Yisrael,

Thank you so much for this information. Going to work on it now. Appreciate it that you broke it down in understandable steps!

Linda Lou

Hey Linda,

Im new to Wix code and am not very well versed in JavaScript. I’m trying to change the date format on a repeater but am having some trouble. I would like the date to displays like this:

August 18, 2018

I tried using your code to change the month format in conjunction with some other code to get rid of the time information… but I cant seem to get it to work haha. My database is named ‘Articles’, and the text box that displays the date information on the repeater is named ‘text70’ Any and all help would be greatly appreciated. I love Wix Code… this is just all very new to me!

$w.onReady(function () {

$w("#Articles").onReady( () => { 
$w("#repeater2").forEachItem( ($w) => { 
	
		function formatDate(date) { 
		 const monthNames = [ 
		    "January", "February", "March", 
		    "April", "May", "June", "July", 
		    "August", "September", "October", 
		   "November", "December"]; 

	 		 let day = date.getDate(); 
			 let monthIndex = date.getMonth(); 
			 let year = date.getFullYear(); 

 				return monthNames[monthIndex] + ' ' + day + ', ' + year;  } 

	let today = new Date(); 
	let str = formatDate(today); 
console.log(str); 

	const OldDate = $w("#text70").text; 
	const NewDate = formatDate(OldDate); 
        $w('#text70').text = NewDate; 
     console.log('Time removed from Date/Time Stamp: New Date ' + NewDate); 
}); 

});

Hey Matt,
I’m unable to help you with that. I kind of gave up on the date issue, I tried without success and then had too many other things to do. Maybe Yisrael can help you?
If you don’t hear anything back, I suggest you copy you question and start a new thread.
Cheers,
Linda Lou

P.S. I love Wix Code too, it opens lots of possibilities!

Thanks Anyway!

if anyone still needs help with this check out https://www.wix.com/code/home/forum/questions-answers/date-created-timestamp-issues