我在这个合作伙伴"YYYY/MM/DD"中约会.现在我想从这种格式中获取一天.我如何使用javascript或jquery获取它?一种方法是这样
$(document).ready(function() {
var d = new Date();
alert(d.getDay());
} );
Run Code Online (Sandbox Code Playgroud)
但这里的问题是d变量包含这种格式的日期
Sat Jan 07 2012 18:16:57 GMT+0200 (FLE Standard Time)
Run Code Online (Sandbox Code Playgroud)
我怎样才能以上述格式获取日期?
这是我的功能的样子
function dayOfWeek(d) {
var dayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Sunday');
var currentDate = Math.round(+new Date(d)/1000);
var nData = new Date(currentDate);
//alert(nData);
//alert(nData.getDay());
//var day = d.split("-")[2];
//var t = day.replace("0","");
//alert(t);
return dayNames[nData.getDay()];
}
Run Code Online (Sandbox Code Playgroud)
我正在做的是我以"YYYY-MM-DD"格式传递日期,它将该日期转换为unix时间戳,然后我得到那天,然后将这一天作为星期日或星期一等返回.但这里它只返回星期五是不正确的.当我更改日期时,它应该在数组中返回同一天.
对不起,如果这是一个基本问题.但我打算为我的网站制作api.首先这个api将由我使用,但后来我将发布给开发人员使用它.我很困惑,这个网站将用于移动应用程序和网站.我打算为此制作Android应用程序.
问题是我是否必须使用不同的语言制作这个api,例如用于Android平板电脑的Java,用于iOS的目标C和用于网络的javascript和php?
如果我只在javascript中制作它,它会适用于多个平台吗?
我正在尝试运行android项目.项目在项目文件夹上有一个红色的x,但子文件夹中没有一个具有红色x.没有突出显示错误的代码.不幸的是,我的项目都没有执行.当我作为项目运行它说这个错误.

它也没有在问题标签中显示任何错误.
我该如何解决这个问题?
我的java构建路径

编辑
这是我的代码
public class AndroidLoginActivity extends Activity implements OnClickListener {
EditText username, password;
Button login;
String user, pass;
HttpClient httpclient;
HttpPost httppost;
ArrayList<NameValuePair> nameValuePair;
HttpResponse response;
HttpEntity entity;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initialise();
}
private void initialise() {
// TODO Auto-generated method stub
username = (EditText)findViewById(R.id.etUsername);
password = (EditText)findViewById(R.id.etPassword);
login = (Button)findViewById(R.id.btnLogin);
login.setOnClickListener(this);
}
public void onClick(View v) {
httpclient = new DefaultHttpClient();
httppost = new HttpPost("http://10.0.2.2/android_login/index.php");
user = username.getText().toString();
pass = …Run Code Online (Sandbox Code Playgroud) 我在android上传图片.目前我的代码只上传文件,但我也想发送一些参数.我正在努力追随
FileInputStream fileInputStream = new FileInputStream(sourceFile);
URL url = new URL(upLoadServerUri);
conn = (HttpURLConnection) url.openConnection(); // Open a HTTP connection to the URL
conn.setDoInput(true); // Allow Inputs
conn.setDoOutput(true); // Allow Outputs
conn.setUseCaches(false); // Don't use a Cached Copy
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("ENCTYPE", "multipart/form-data");
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
conn.setRequestProperty("uploaded_file", fileName);
dos = new DataOutputStream(conn.getOutputStream());
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\"uploaded_file\";filename=\""+ fileName + "\"" + lineEnd);
dos.writeBytes(lineEnd);
//Sending data
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\"paramName\"" + lineEnd);
dos.writeBytes(lineEnd); …Run Code Online (Sandbox Code Playgroud) 我有一个函数,我首先检查作为参数传递的字符串是否只有字母.但它总是以虚假的方式回归.下面是我的jsfiddle
function takeString (str) {
var regex = "/^[A-Za-z]+$/";
if (str.match(regex)) {
if (str.charCodeAt(0) === str.toUpperCase().charCodeAt(0)) {
alert('true');
return true;
}
else {
alert('false');
return false;
}
}
else {
alert('Only letters please.');
}
}
takeString('string');
Run Code Online (Sandbox Code Playgroud)
以上代码始终提醒Only letters please.
我正在为nodejs 使用Microsoft Cognitive Services api.我有以下代码
const cognitiveServices = require('cognitive-services');
const face = new cognitiveServices.face({
API_KEY: yourApiKey
})
const parameters = {
returnFaceId: "true"
returnFaceLandmarks: "false"
};
const body = {
"url": "URL of input image"
};
face.detect({
parameters,
body
})
.then((response) => {
console.log('Got response', response);
})
.catch((err) => {
console.error('Encountered error making request:', err);
});
Run Code Online (Sandbox Code Playgroud)
但是,当我执行此代码时,我得到以下错误
const face = new cognitiveServices.face({
^
TypeError: cognitiveServices.face is not a constructor
at Object.<anonymous> (/Users/..../face.js:3:14)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at …Run Code Online (Sandbox Code Playgroud) 我正在使用vim-airline插件工作得非常好,但是在标签之间切换的唯一方法是用户:bp or :bn,这是快捷方式:bprevious or :bnext.这个问题是,如果我在第一个选项卡上并想要切换到最后一个选项卡,即第10个选项卡,那么我必须键入:bn十次才能到达那里.我该如何直接切换?也许紧迫的事情arrow keys会有益.
我正在使用带骨干应用程序的Backbone.LocalStorage插件.它在chrome和safari中运行良好,但它在firefox中给出了我的错误.
DOMException [SecurityError:"操作不安全." 代码:18 nsresult:0x80530012位置:http:// localhost:8000/js/libs/backbone.localStorage/backbone.localStorage.js?version = 1453910702146:137]
我正在使用python simpleHttpServer
我该如何解决这个错误?
UPDATE
这是我的代码.
paths: {
'jquery' : 'libs/jquery/dist/jquery',
'underscore' : 'libs/underscore/underscore',
'backbone' : 'libs/backbone/backbone',
'localStorage' : 'libs/backbone.localStorage/backbone.localStorage',
'text' : 'plugins/text'
}
Run Code Online (Sandbox Code Playgroud)
这是使用localStorage的集合.
var Items = Backbone.Collection.extend({
model: SomeModel,
localStorage: new Backbone.LocalStorage('items'),
});
Run Code Online (Sandbox Code Playgroud)
更新2
我正在使用firefox 36.
更新3
看起来这是一个CORS问题,但我的firefox版本是36.哪个应该没问题.
更新4
我也在firefox nightly版本44中收到此错误.我还将我的firefox更新为版本44.仍然是同样的错误.
嗨,我想撤消我的最后一次提交.我做的是我对文件进行了一些更改然后我提交了它们但是我还没有将它们推送到主回购.在git commit -m"comment"命令之后我运行了git status并得到了这条消息
Your branch is ahead of 'origin/demo' by 1 commit
Run Code Online (Sandbox Code Playgroud)
所以现在我要撤消我的最后一次提交,那么我该怎么做呢?
正如标题所说,typeof (Array, null)返回object和typeof(null, Array)返回function.
它返回第二个参数的类型.
为什么?