in my project when i run it in chrome it is showing wrong time. explorer it is showing true. So i write this js code but it is still doesnt working.
This is my js;
var FormatTrxStartDate = function (value, record) {
var processDate = new Date(value);
return processDate.getDate() + "." + (processDate.getMonth() + 1) + "." +
processDate.getFullYear() + " " + processDate.getHours() + ":" +
processDate.getMinutes() + ":" + processDate.getSeconds();
};
And this is where i use it;
<ext:ModelField Name="TrxStartDate" Type="String" >
<Convert Fn='FormatTrxStartDate' />
</ext:ModelField>
Pass Parameter Value in not proper Date Format
Use processDate.getFullYear()==> processDate.getFullYear().toDateString() date data convert into String
X.Js.Call("FormatTrxStartDate ",value,record);
please try this code
Related
I'm building an app that will send an email with variables, but i only want to include certain things if a variable is true (checkbox)
So I think i need If statments inside the email.putExtra(Intent.EXTRA_TEXT,""); but I dont seem to figure out how. it would look something like this:
public void Email (){
Date today = Calendar.getInstance().getTime();
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-YYYY HH.mm");
String Time = formatter.format(today);
Intent email = new Intent(Intent.ACTION_SENDTO);
email.setData(Uri.parse("mailto:"));
email.putExtra(Intent.EXTRA_SUBJECT, "Audit" );
email.putExtra(Intent.EXTRA_TEXT, Time + "\n" + "Audit Results:"
if (MainActivity2.Send_A)=true{
MainActivity2.Ok_A1 + "\n" + MainActivity2.EditText1 + "\n" + MainActivity2.POA1
}
);
I know the code is completly wrong, but is it possible to do something like this?
Build up the string, than set that string to your function call.
var extraText = Time + "\n" + "Audit Results: ";
if (MainActivity2.Send_A === true){
extraText += MainActivity2.Ok_A1 + "\n" + MainActivity2.EditText1 + "\n" + MainActivity2.POA1;
}
email.putExtra(Intent.EXTRA_TEXT, extraText);
I need to get field source from JSON but my solution not working !!
this is json:
"trailers":{
"quicktime":[],
"youtube":[{
"name":"BandeAnnonce",
"size":"HD",
"source":"RqEuaM9Fsrg",
"type":"Trailer"
}]
}
i try to get the source :var link_trailer = data.trailers[0].youtube[0].source;
but is not working for me !!
trailers is object, you don't need to use index.
var link_trailer = JSON.parse(data).trailers.youtube[0].source;
Try the following code
var text = '{' +
'"trailers": {' +
'"quicktime": [],' +
'"youtube": [{' +
'"name": "BandeAnnonce",' +
'"size": "HD",' +
'"source": "RqEuaM9Fsrg",' +
'"type": "Trailer"' +
'}]' +
'}' +
'}';
obj = JSON.parse(text);
var source = obj.trailers.youtube[0].source;
document.getElementById("demo").innerHTML ="Source field value is :"+source;
Here is the working jsfiddle:http://jsfiddle.net/NJMyD/5387/
Parse json into object first
var link_trailer = JSON.parse(data).trailers[0].youtube[0].source
I have a Date format like this
2014-11-18T20:50:01.462Z
I need to convert to the custom format like "20:50 2014-18-11" using Javascript date function
I need result like
20:50 2014-18-11
How to get this , Thanks in Advance :)
Assuming you're able to include new libraries on your project, I'd highly recommend moment.js (MIT license) instead of writing this yourself. It solves problems like zero padding etc. for you.
Example
<script src="http://momentjs.com/downloads/moment.min.js"></script>
<script>
// Use an existing date object
var date = new Date("2014-11-18T20:50:01.462Z");
console.log(moment(date).format('HH:mm YYYY-DD-MM'));
// or use string directly
console.log(moment.utc("2014-11-18T20:50:01.462Z").format('HH:mm YYYY-DD-MM'));
</script>
Note by default moment will use your current timezone for output, this can be overridden using the zone() function
console.log(moment.utc("2014-11-18T20:50:01.462Z").zone(0).format('HH:mm YYYY-DD-MM'));
console.log(moment.utc("2014-11-18T20:50:01.462Z").zone('UTC+05:30').format('HH:mm YYYY-DD-MM'));
Output
20:50 2014-18-11
Try moment js its very nice plugin to play around dates and times
so all you need to do is import moment js and put this line in your js code
using moment.js will also help you in future for your code
moment.utc("2014-11-18T20:50:01.462Z").format("HH:mm YYYY-DD-MM")
Use this Demo JsFiddler
var d = new Date,
dformat = [ d.getHours().padLeft(), d.getMinutes().padLeft()].join(':')
+ ' ' +
[d.getFullYear(), d.getDate().padLeft(), (d.getMonth()+1).padLeft()].join('-')
;
Date.prototype._padding = function(v, w) {
var f = "0000" + v;
return ("0000" + v).substr(f.length-w, f.length)
}
Date.prototype.MyDateString = function() {
return this._padding(this.getUTCHours(), 2) + ":" + this._padding(this.getUTCMinutes(), 2) + " " + this.getUTCFullYear() + "-" + this._padding(this.getUTCDate(), 2) + "-" + this._padding((this.getUTCMonth() + 1), 2);
}
console.log(new Date('2014-11-18T20:50:01.462Z').MyDateString())
console.log(new Date('2014-11-08T02:05:01.462Z').MyDateString())
getUTCMonth return 10, as the month is 0 based.
I am calling a function with one parameter "modalXPTO.HtmlFieldPrefix" sucessfuly like this:
modalXPTO.AdditionalJavaScriptCallback = "myFunction('" + modalXPTO.HtmlFieldPrefix + "')";
However, I would like to send more than one parameter, and I would expect this should work:
modalXPTO.AdditionalJavaScriptCallback = "myFunction('" + "{parentContainer:" + modalXPTO.ModalDivId + ", htmlFieldPrefix:" + modalXPTO.HtmlFieldPrefix + "}" + "')";
But it doesn't. Can anyone tell me what I am missing?
Here is the myFuntion declaration:
function myFunction(arg){
alert(arg.htmlFieldPrefix);
alert(arg.parentContainer);
}
I've fixed it.
modalXPTO.AdditionalJavaScriptCallback = "myFunction(" + "{parentContainer:'" + modalXPTO.ModalDivId + "', htmlFieldPrefix:'" + modalXPTO.HtmlFieldPrefix + "'}" + ")";
It is because of the misplaced "'". I wanted to pass an object with two parameters, but because of these characters I was passing a string instead.
How can I convert a python timestamp with javacript
from 2014-07-28T20:45:04.271935
to 1.6.2014 (20:45)
I tried to use the builtin parse function from javascript, but it seems to mix up things..
out = new Date(context);
out = out.getDay() + ". " + out.getMonth() + ". " + out.getFullYear() + " (" + out.getHours()+ ":" + out.getMinutes() + ")";
If you work with date and time intensively in your application I'd recommend you to use Moment.js library for painless conversions:
moment('2014-07-28T20:45:04.271935').format('D.M.YYYY (H:m)');
// Will return "28.7.2014 (20:45)"
moment('2014-07-09T20:45:04.271935').format('DD.MM.YYYY (H:m)');
// Will return "09.07.2014 (20:45)"
And if you need to format the date and time only in one place then just build the string manually as you did in your code example.