我使用它来获取一系列日期以确定是否删除元素,但我如何编辑它以便我不必输入年份值。那么有一种方法可以设置变量而无需输入年份值吗?
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
}
答案 0 :(得分:1)
尝试使用.toJSON
,String.prototype.slice
var findDate = new Date();
var displayModule = new Date("August 2"); //SET STARTING DATE YOU WANT MODULES DISPLAYED
var hideModule = new Date("January 4"); //SET ENDING DATE YOU WANT MODULES REMOVED
if (findDate.toJSON().slice(5, 10) > displayModule.toJSON().slice(5, 10)
&& findDate.toJSON().slice(5, 10) < hideModule.toJSON().slice(5, 10)) {
// do stuff
} else {
$("#InvalidLineup").remove();
$("#IRviolations").remove();
}
e.g;
var findDate = new Date();
var displayModule = new Date("July 31");
var hideModule = new Date("August 2");
if (findDate.toJSON().slice(5, 10) > displayModule.toJSON().slice(5, 10)
&& findDate.toJSON().slice(5, 10) < hideModule.toJSON().slice(5, 10)) {
// do stuff
alert("ok")
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
&#13;