How to convert this type of data from angular material datepicker
dateFrom: '2018-10-03T16:00:00.000Z'
to this type of data, generated by Date.now ?
dateFrom : '2018-10-10 14:50:16.479'
then I will use the data in my query
Use moment
console.log(moment('2018-10-03T16:00:00.000Z').format('YYYY-MM-DD HH:mm:ss.SSS'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
Here is a good cheat sheet
https://devhints.io/moment
Related
all
I am looking for a simple way to add today's date in my marp markdown. Something like
{{ date }}
Any idea?
Thanks
Here is one way using the Date() function in JS. This could then be customised to display exactly what you wanted (date, time, specific date format etc.)
With this method though, if viewing as a HTML slide deck then the datetime will change each time the page is loaded.
If you wanted to insert a static time (e.g. file save date etc), perhaps the easiest way would be to just do a regex replace on a certain phrase eg. {{ date }} as above, before you get Marp to convert the document.
---
marp: true
---
Refresh to see changes...
<p id="date1"></p>
<p id="date2"></p>
<p id="date3"></p>
<script>
const now = new Date()
document.getElementById("date1").innerHTML = now;
document.getElementById("date2").innerHTML = now.toLocaleDateString("en-US");
document.getElementById("date3").innerHTML = now.toLocaleDateString("en-US", {weekday: 'long'});
</script>
I have a model with many datetime properties, in this i have LastUpdatedTime property which i am using for Concurrency functionality and will not be binding to any control in view. and this datetime properties rendering in client side as /Date(1224043200000)/, while saving in mvc controller, it is not recognizing /Date(1224043200000)/ as valid format and taking default date and failing the save operation. so any common solution after fetching the model and before rendering in view, so that i can change the format for all datetime properties in the model.
Assuming that the date value you have in your controller as var /Date(1224043200000)/
Use the below code
HTML
<body ng-controller="MainCtrl">
<p>Hello ASP DATE ISSUE </p>
{{dateValue.slice(6,19) | date}}
</body>
JS
var app = angular.module('aspDateApp', []);
app.controller('MainCtrl', funscope) {
$scope.name = 'ASP DATE ISSUE';
$scope.dateValue='/Date(1224043200000)/';
});
LIVE DEMO
You should extract the milliseconds part from "/Date(1224043200000)/" (1224043200000) and Convert it into valid date format and bind it into the relevant attribute of your model.
var datetimeInMilliseconds = parseInt("/Date(1224043200000)/".match(/\(([^)]+)\)/)[1]);
var convertedDateTime = new Date(datetimeInMilliseconds);
ArrayName.AttributeName = convertedDateTime ;
I am using time datatype in sqlserver 2008 database to save time.
I want to display this time in Kendo ui grid in mvc 5.
I can read this in c# with timespan datatype and giving this as json data to the kendo ui grid.
this is the Json response we are getting.
"Data":[{
"CCdate":"\/Date(1418322600000)\/",
"CCDay":"Friday",
"Status":true,
"OpeningHour":{"Hours":10,"Minutes":0,"Seconds":0,"Milliseconds":0,"Ticks":360000000000,"Days":0,"TotalDays":0.41666666666666663,"TotalHours":10,"TotalMilliseconds":36000000,"TotalMinutes":600,"TotalSeconds":36000},
"ClosingHour":{"Hours":5,"Minutes":0,"Seconds":0,"Milliseconds":0,"Ticks":180000000000,"Days":0,"TotalDays":0.20833333333333331,"TotalHours":5,"TotalMilliseconds":18000000,"TotalMinutes":300,"TotalSeconds":18000}
}]
OpeningHour and ClosingHour are my timespan objects
How do I display these time span objects in kendo ui grid in 12 hour format.
Try like this,
Format your grid column like this,
{
field: "OpeningHour",
title: "Opening Hour",
format: "{0:MM/dd/yyyy h:mm tt}"
}
See this link : http://docs.telerik.com/kendo-ui/framework/globalization/dateformatting
I got a currency exchange script from coinmill. I want to modify it to work nice in my page. I am a newbie in html/javascript programming thats why i am asking help on this one, pls.
<script src="http://coinmill.com/frame.js"></script>
<script>
var currency_round=true;
var currency_decimalSeparator='.';
var currency_thousandsSeparator=',';
var currency_thousandsSeparatorMin=3;
</script>
$199.00 (US) = <script>currency_show_conversion(199.00,"USD","GBP");</script> GBP<br>
<small>Currency data courtesy coinmill.com</small>
This scripts works fine but shows the conversion for the default value in the script. I need to replace the value ($199.00) to a value from a textbox of id "edit_1". Automatically after the user inserts the currency to exchange, the value will show in the page.
Thanks in Advance.
I am Stephen Ostermiller, and I run http://coinmill.com/. You can make this work with the JavaScript currency API from Coinmill:
Put on onchange event on the textarea
Get the value from the text area using this.value
use the currency_convert(value,from,to) method that is available in frame.js to convert it into the currency of your choice
Write the value to where you want it in the page, for example with document.getElementById('results').innerHTML
Putting it all together:
<script src="http://coinmill.com/frame.js"></script>
<script>
var currency_round=true;
var currency_decimalSeparator='.';
var currency_thousandsSeparator=',';
var currency_thousandsSeparatorMin=3;
</script>
<textarea id=edit_1 onchange="document.getElementById('results').innerHTML=currency_convert(this.value,'USD','GBP')"></textarea><br>
Converted into GBP:<div id=results></div>
<p><small>Currency data courtesy coinmill.com</small></p>
Whene I enter "273" into the textarea, I then see "Converted into GBP: 176.32" on the page.
You can test out a live example on jsfiddle: http://jsfiddle.net/wAxnq/
I am developing android app using jquery mobile. i want to change default date format for input type = "date". how can do this?. one more thing from where the date picker is loading?
anyone help ?
eg:-
it is displaying date in following format by default: "mm/dd/yy". but i need to set this date format dynamically. How can i do this?
set
input_type = TYPE_DATETIME_VARIATION_DATE
in your android.text field. this allows entering only a date.
you can parse it in your java script by doing this :
DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy", Locale.getDefault());