Search code examples
angularangular4-httpclient

How to fetch client system Date and Time on page load in Angular 4


I am working in a Angular 4 project ,In this I need to get the client system's Date and Time on page load and pass it to the API for storing the data in MSSQL server.

I have done all the API and MSSQL parts but I Don't know how to get the Client system's date and time ...


Solution

  • On Angular (so TypeScript) new Date() get the current date and time, so:

    let myDate: Date = new Date();