Date only!

hi there

well in my data set i have a column that related to date and time. As the data is to be taken from User i had initiate it us Date&Time, which is great for date picker
But!
when i want to present the data in another page i get in issue where i only want to show date BUT it shows date and time

therefore, is there a way to present only date without the time!?

Hi 3shtar,

At the moment the date picker element only displays the date, simply add it to the page, connect it to the correct data and it should solve the issue.
By default the element is enabled and visitors are able to modify the date value.
To prevent users from modifying data, untick ‘Enable by default’ in the element’s properties windows to disable it.

Note that disabled elements are greyed out. To fix this, simply edit the design to make it appear enabled:
Click the date picker element > ‘Design’ > ‘Customize Design’ > Select the ‘Input Field’ tab > from the dropdown list select ‘Disabled’ and change the color scheme to make it appear enabled.

Dear Ido,

well let me try to re write my question as seems your answer was not to my question

i have 2 pages
page 1 : user input | he can input date by date piker
page 2 : shows user inputs | here my issue with presenting date only!

so, is there a way to show only DATE without time ?

hope this is easier to follow

3shtar, what Ido was trying to explain is that you can use an INPUT element (date picker) for OUTPUT. But then you have to disable the calendar function, thus you disable it, thus it goes grey, thus you change the disabled color.
If you don´t want that, you can roll your own, or as I did months back, like this:

function convertLongDate(DateIn) {
let thisDay = DateIn.getDate();
let strthisDay = “0” + thisDay.toString();
strthisDay = strthisDay.substr(strthisDay.length - 2, 2);
let thisMonth = DateIn.getMonth() + 101;
let strthisMonth = thisMonth.toString();
strthisMonth = strthisMonth.substr(strthisMonth.length - 2, 2);
let thisYear = DateIn.getFullYear();
let formattedDate = strthisDay + “/” + strthisMonth + “/” + thisYear;
return formattedDate;
}

Note that it returns a date formatted as DD/MM/YYYY, but you can easily change that. ALso be sure to check before (or inside) on Null or Undefined.
Good luck.

Hey Giri zano thanks for that quick tip- so I added the date input field, made it read only, and linked it to the database and voila the date only appears, with no hours. Thanks

Hi Lorraine,

You got it right. If you add a datepicker and connect it to a read-only dataset the datepicker will display the date only, no time. And there’s no need to disable anything manually or change the styling. The input is automatically disabled because the dataset is read-only.

-Jeff

3shtar, we also came up with alternative method for the timestamp if you want to check the post: https://www.wix.com/code/home/forum/questions-answers/date-created-timestamp-issues

Hey guys,

JavaScript has a bunch of functions for controlling how dates are displayed. Below I used “toLocaleDateString()”, which formats a date as a string based on your settings, including the language. You can read more about it here .

$w.onReady(function () {	
    // Get the date from the date field of the current item
    const date = $w("#myDataset").getCurrentItem().date;
	// Define date preferences
	const options = {
        weekday: "short",
        year: "numeric",
        month: "long",
        day: "numeric"
    };
    // Display the date in the text using the defined language and options
    $w("#text1").text = date.toLocaleDateString("en-US", options);
});


1 Like

Hi, I’m trying to connect the date picker to my database’s created date but the item is in grey, I can’t select it. Any idea why?

Thanks

Hi SharonD

Dont know why but the code seems not working
I did copy it and change the date to my DB dateField and put onReady Function.

I did try it both for DB and DynamicPage. I am exepcting to get result like Day/Mon/Year without the time .

Also it this possible to us DB_onCurrentIndexChange?

Thanks,
DA

Hey,

Sorry to hear that. Can you share your code?

Hi SharonD

Thanks, I found much better way that suits the event function on my page.

DA

Any tips on how to get to show date in week day format? I would like to display “today,” “tomorrow” “Monday” “Tuesday” etc. It’s for an events listings website. Any advice is greatly appreciated.

Nelson

Hi SharonD,
I’ve tried the following code, as you recommended, on dynamic page. Dont know why, but the code seems not working.
Do you have any idea why?
All the best,
Tzuriel

$w.onReady(function () {    
 const date = $w("#dynamicDataset").getCurrentItem().OrderDate;
        const options = {
        weekday: "long",
        year: "numeric",
        month: "long",
        day: "numeric"
    };
    $w("#text41").text = date.toLocaleDateString("en-US", options);
});
1 Like

Hi Tony,

Quite a while has passed since this post was first put up in the wix code forum, however I am just reading it now myself and came across your post here.

It might all be irrelevant now for you though, your date picker above, you needed to connect it to a new field which is a ‘date and time’ field in that dataset.

You were trying to connect to the created date which is the date that the actual entry in the dataset itself was entered. The same with the updated date, that would be when the dataset entry was updated.

These created and updated date fields are normally hidden in datasets unless you choose to view them.

For example if you have a members dataset for a members profile area, then the created date would be when that member created their entry into the members dataset, with the updated date being the date when they last updated any info on their profile.

Apologies if this is already known and not needed!

I’m new to data collections. I’d like to display daily organisational times and events via a date picker calendar. Can someone kindly advise how I can set up data, connect to it then allow users to display events lists from each calendar day, via a dataset?

Why not just use Wix Events
https://support.wix.com/en/wix-events/setting-up-wix-events
https://support.wix.com/en/article/choosing-which-events-to-display-on-a-site-page-in-wix-events

If you want a easy and simple way, then just use Google Events Calendar app.
https://support.wix.com/en/apps-made-by-wix/google-event-calendar

If you want to do it through code in a table or repeater for example, then look at the DatePicker info and it will give you examples.
https://www.wix.com/corvid/reference/$w.DatePicker.html

How do I let site visitors search or filter my site content according to date?
Let visitors enter a date via a date picker. Then query your database collection or filter your dataset for items with the selected date.

If you use Repeaters, then make sure that you have a read of the info for it too as you will need to use forEachitem.
https://www.wix.com/corvid/reference/$w.Repeater.html

This previous forum post should help you too.
https://www.wix.com/corvid/forum/community-discussion/filtering-repeater-by-date

Guys, the date Calendar Picker field in forms is really terrible, how do I make it in a simple normal way? So the user can only write numbers and it automcatically fills in MM/DD/YYYY numbers

Please open your own post, instead of bumping up old ones.
Yes there is a SOLUTION for you! See you in your own post :wink:

You can generate an own Date-Time-Converter if you want, everything is possible!