I have a form that contains a Datepicker and in the email that is sent on submission the date is formatted with a time.
How do I remove the time from the date?
Thanks
You can either change the property to just Date, without the time element, or you can use ToString() method for the DateTime within C#:
https://msdn.microsoft.com/en-us/library/zdtaw1bw(v=vs.110).aspx
The format without time would look something like this:
yourDate.ToString("DD/MM/YYYY");
Related
I have a popup with kendo grid inside that displays records, the first column is
col.Bound(m => m.RecordDate)
.EditorTemplateName("DateTime")
.Width(180).Format("{0:dd/MM/yyyy h:mm tt}");`
This is the DateTime in EditorTemplate -
#(Html.Kendo().DateTimePickerFor(m => m)
.HtmlAttributes(new { data_bind = dataBind}))`
The problem is when I go to that view, and create a record let's say current datetime is 19/10/2017 8:30 AM when i save the record it get's the correct time, the grid is reloaded but the popup is not being closed and then let's say 3 minutes have passed, and I create a record again but the datetimepicker's default value is still 19/10/2017 8:30 AM, instead of 19/10/2017 8:33 AM
Since the window is not being closed then the binded dateTime to the datePicker will allways the be the dateTime that was binded the first time the window was loaded. The element doesn't refresh and there isn't any configuration for it to always get the current DateTime since it is not possible.
If for example you open any window and until your save a couple of minutes have passed the value of the dateTime will again be wrong. If you want the absolute moment of the save you can't give it to the user to insert it or alter it. You should set it at the save event at that exact moment that the save occurs
If however you still want to allow the user to handle that dateTime one way I can think of is to reset the dateTimePicker value to Date.now() every time the user focuses to the window. Obviously you will still have the issue of the time passing while the user inserts his data...
I'm writing DateTime Formatter in ASP.NET MVC and need to format the datetime based on cultural info.
My model's property binds DateTime.Now volue to the view and as a result the view is displaying 3/21/2017 9:38:37 AM as a datetime.
I'm looking for the way to display 3/21/2017 or 21/3/2017 and etc based on the culture.
What is the best way to do it. I tried a few examples from
https://msdn.microsoft.com/en-us/library/5hh873ya(v=vs.90).aspx
<span>String.Format("{0:d}", #Model.ToString())</span>
But the view still display the full datetime value: 3/21/2017 9:38:37 AM
I know that might be easy question but anywhere need some input on that.
What is the best way to handle something like that?
C# has come helpers built into the DateTime class. You can do this to only get the date.
DateTime.Now.ToShortDateString();
Or using your code assuming mode is an instance of DateTime:
#Model.ToShortDateString()
I will use date picker in rails application. My attribute type are date and datetime.
If I use bootstrap-datepicker-rails gem, should I change them to string?
If not, how to use the datepicker in simple-form?
The answer in StackOverview says that If your attribute using datetime type, you can use bootstrap-datetimepicker-rails gem, how to use it?
Thanks.
Rails model attributes can be datetime and date. Just make the form input fields text, not date or datetime.
I'm new in ax2012 and i create a new table with a field of type date, then i create new form to submit rocords
In form a create a new dateEdite control and in EDT property I specified TransEdite to show icon calendare in form.
My problem is when i try submit form, i can't insert date value in date field.
how can I fix that?
Best regards
Can you check that DataField and DataSource of the forms control are pointing to your date field on the table?
If it is a transaction table you are creating, best make use of EDT "TransDate" as data type.
I have a date field in my grid. I can't seem to figure out how can I turn off the validation if a user doesn't enter a date. In my data model the date property is not decorated with required attribute. Also in the database that I am using the date column is allowed a null and has a default value. I also turned off the Client Validation in the web config file. But still can't figure out why the date field has client validation turned on. The telerik version I am using is 2011.2.712.340.
So I was able to find out how to turn off the client validation if the user is not required to enter a date while filling a form. When declaring the data model if you have the property to as nullable:
public DateTime? YourDateProperty {get; set;}
then you can edit or insert a new record. In my case I had the date field as one of the columns in the grid and I was having problems where I could not insert a new record without the user having to enter a date.