Changing standard settings date field

I have 2 questions regarding a date field while customizing a form:

  • is it possible to have the date change automatically to the date of today?
  • it is possible to add the day of a date field?

@Rutger

Yes! It’s possible to automatically pop up today date while form loading.
Solution:
You can do this through Custom Form → Date Field.
In Date Field → Default value Enter Today and update the form.

Next time when you’ll open your form it’ll automatically pop up default Date as date of Today.

For Second question it’s not directly possible, but there is way to do it. Just add new data field and update the value of data field from date.
Eg:
date_val = cur_frm.doc.date_field.split(“-”)[2];

Now you can set this value to new data field date_val.
Thanks
Navdeep

Hi Navdeep,

Thank you for helping me out.

For question 1 my value was already set to Today but each time when I load the form it doesn’t refresh itself to Today. Could it be it only does it the first time when you create the form?

For the 2nd option i got a lot of errors. Unfortunately I’m not an expert here.
What I wanted to do is to show the date like Mon 2nd Jul 2017 instead of 2nd of July. Shouldn’t this be an extra setting of ERPnext as you would normally with you computer system as well. For instance the mac gives you this option in the top right corner.

Thanks again.

Rutger

@Rutger

You may create Custom script to handle it.
For First Question:
Just try to add function on form refresh event in Custom Script. For example.
frappe.ui.form.on(“Doctype Name”, “refresh”, function(doc){
// Write your logic here
});

For Second Question:
You may do same thing for it. Create Custom Script and then create function to handle your date and format.

Frappe already linked many functions with frappe.datetime object. You can use frappe.datetime.[function_name] according to your requirement.
For Example:
// this will return today date.
today = frappe.datetime.now_date();

For more detail visit this link:

Thanks