Display Current DateTime in SQL format (yyyy-MM-dd HH:mm:ss) in AngularJS

Last Reply one month ago By dharmendr

Posted one month ago

How to pass current date time in sql format in angularjs and insert the current date using post method in angularjs and also in web api

For Eg :

The required output format is 2019-05-28 09:30:08.730


You are viewing reply posted by: dharmendr one month ago.
Posted one month ago

Hi skp,

Check this example. Now please take its reference and correct your code.


<html xmlns="http://www.w3.org/1999/xhtml">
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.8/angular.min.js"></script>
    <script type="text/javascript">
        var app = angular.module('MyApp', []);
        app.controller('MyController', function ($scope) {
            $scope.DateTime = new Date().toISOString().slice(0, 19).replace('T', ' ');
    <div ng-app="MyApp" ng-controller="MyController">