Timularamp in datetime format in input field

I save the datetime in the timestamp line using the following:

date_default_timezone_set('Europe/London'); 
$bdatetime = "31-03-2016 21:52";
            $date = new DateTime($bdatetime);
            $bdatetimeTS = $date->getTimestamp();

which saves a fine. And I can get this timestamp and convert it back to its original format using the following command in angular js:

<td>{{item.bdatetime * 1000 | date:'dd-MM-yy'}}</td>

which displays the entire list of entries.

Now I need to edit individual records, in the editing form I have the following field:

<input type="text" ng-model="bdatetime" value="{{bdatetime * 1000 | date:'dd-MM-yy'}}" name="bdatetime" id="datetimepicker" required/>

in JS and binding it using the following:

$scope.bdatetime = data[0].bdatetime;        

which shows the timestamp in the input field, and then shows the time date in a format in a specific format.

I know how to convert timestamp to datetime format for non-bindable .

How to do this for a bindable input field?

, .

+4
2
var timestamp = data[0].bdatetime;
var date = new Date(timestamp * 1000);
var datevalues = ('0' + date.getDate()).slice(-2) + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + date.getFullYear() + ' ' + date.getHours() + ':' + date.getMinutes();
$scope.bdatetime = datevalues;
+1
0

Source: https://habr.com/ru/post/1526177/


All Articles