TanvirArjel
TanvirArjel

Reputation: 32069

ngx-bootstrap DatePicker DateTime issue in Angular5

I have a SQL Server database field named 'JoiningDate' which has the type date (no time part here).To Capture the input from the user I am using ngx-bootstrap datepicker but the problem is that whenever I select a date from the datepicker, the datepicker itself converting the selected date into utc datetime as follows:

enter image description here

Sometimes it mismatches the date part due the utc time part.

My questions are:

  1. How can I get the the selected date as plain string like jQueryUI Datepicker?
  2. What is the best option get the input date exactly as it shown in input field?

Upvotes: 2

Views: 1786

Answers (1)

Hameed Damee
Hameed Damee

Reputation: 321

You will need to write a simple function to convert the date object to the locale date string in format ("10/31/2018"), just as it is displayed in the input field:

convertDate(inputDate) {  
    // convert date received to locale string in 10/31/2018 format  
    const localeDate = inputDate.toLocaleDateString();  
    return localeDate;  
}

Upvotes: 1

Related Questions