This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

rnicrosoft
rnicrosoft

in this http://octobercms.com/docs/backend/forms#widget-datepicker

how to set date picker's default value as present time, which is when the visitor open the form page?

I have tried to replace with php code and put php code into localization file, and both of above won't work.

Shantarli
Shantarli

Recently I've found this solution on the forum. I know, this is strange, but it works for me. I guess the reason why this is happening in my case - the wrong format in date picker by default or i dont know. Maybe someone else will suggest the correct solution

use Carbon\Carbon;

public function getCreatedAttribute($value){
  return Carbon::parse($value)->format('Y-m-d');
}
Zmove
Zmove

Another solution, in the fields.yaml file, put

default: now

for the datepicker widget type.

tech.computeraid55120
tech.computeraid55120

The reason is simple. I have faced this with many platforms and frameworks. Here are my two cents. The date picker is being "run at server". Let's say you use a shared host like Godaddy. Then, this would mean that the datepicker would pick up the current date and time of the server irrespective of where the user is accessing it in the world.

While using simple PHP, its easy to get current date and time in the client end and then inject that in the date picker in the default value in case you are wanting to get current date and time.

I am having a tough time cracking october cms controls as the documentation is thin.

For some reason setting the time zone as UTC+5:30 in config/app.php doesn't work for me either.

I am in Indian ST.

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.