Click here to Skip to main content
15,887,975 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I want to show only the date, I try like this;

C#
$("#popupEventForm").find("form").find("#eventDate").val(calEvent.start).toString("MM/dd/yy");


this is are C# properties:


C#
public JsonResult GetDiarySummary(double start, double end, string Title)
        {
            var ApptListForDate = DiaryEvent.LoadAppointmentSummaryInDateRange(start, end, Title);
            var eventList = from e in ApptListForDate
                            select new
                            {
                                id = e.ID,
                                title = e.Title,
                                appointmentLength = e.AppointmentLength,
                                start = e.StartDateString.FormatWith("MM/dd/yy"),
                                scheduledTime = e.StartDateString,
                                end = e.EndDateString,
                                someKey = e.SomeImportantKeyID,
                                allDay = false
                            };
            var rows = eventList.ToArray();
            return Json(rows, JsonRequestBehavior.AllowGet);
        }
Posted
Updated 30-Jan-15 8:05am
v2
Comments
ZurdoDev 30-Jan-15 13:48pm    
.toString() in JavaScript, as I recall, does not support passing date format strings.
Anurag Gandhi 30-Jan-15 13:57pm    
Are you looking for removing time part from DateTime string?
.val() returns string, not date varialbe. so, you are applying toString on string variable.
Try something like:
value.replace(/\d{1,2}:\d{2}(AM|PM)/ig, '');
to remove time part.
[no name] 30-Jan-15 14:04pm    
Thank you, but like this:


$("#popupEventForm").find("form").find("#eventDate").val(calEvent.start).replaceWith(/\d{1,2}:\d{2}(AM|PM)/ig, '');

because: value.replace doesnt exist
Sinisa Hajnal 31-Jan-15 2:40am    
Use moment.js, Date.js or some other library that enables you to format dates.
[no name] 31-Jan-15 6:45am    
Ok, thank you

1 solution

I solved, like this:

C#
rec.StartDateString = item.DateTimeScheduled.ToString("MMMM/dd/yyyy");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900