Getting Current Date as String

Hi there,

I was wondering if anybody knew if it was possible to get the currently viewed month as a string from SfSchedule in monthview?


Thanks

1 Reply

VR Vigneshkumar Ramasamy Syncfusion Team August 31, 2018 11:25 AM UTC

Hi Peter Waugh 
 
Thanks for contacting Syncfusion support. 
 
We have checked with your query. In SfSchedule, you can get the current date of Month view as string by using VisibleDates property of VisibleDatesChangedEventArgs in VisibleDatesChanged event. We have prepared a simple sample to get current date as string using VisibleDatesChanged event. Kindly refer the code snippet and sample below.  
  
Code snippet:  
        schedule.VisibleDatesChanged += Schedule_VisibleDatesChanged;  
        …  
        private void Schedule_VisibleDatesChanged(object sender, VisibleDatesChangedEventArgs e)  
        {  
            var count = e.VisibleDates.Count();  
            var dateFormat = new SimpleDateFormat("MMMM dd yyyy");  
            var currentDate = e.VisibleDates.FirstOrDefault(calendar => IsCurrentDate(calendar));  
            if (currentDate == null || e.VisibleDates[count / 2].Time.Month != Calendar.Instance.Time.Month)  
                button.Text = "" 
            else  
                button.Text = dateFormat.Format(currentDate.Time);  
        }  
  
SampleScheduleAndroid  
  
You can also refer our online User Guide Documentation by using the below link.  
  
Regards  
Vigneshkumar R 


Loader.
Up arrow icon