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!?
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.
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
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.
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);
});
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.
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
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?
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.
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