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

skp
 
on Jul 12, 2019 01:43 AM
Sample_191860.zip
1906 Views

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

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jul 12, 2019 06:56 AM

Hi skp,

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

HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <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', ' ');
        });
    </script>
</head>
<body>
    <div ng-app="MyApp" ng-controller="MyController">
        {{DateTime}}
    </div>
</body>
</html>

Demo