www.91084.com

GVKun编程网logo

PHP返回正确的时间(php返回正确的时间函数)

8

对于PHP返回正确的时间感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解php返回正确的时间函数,并且为您提供关于API网关未返回正确的模板、c–ifstreamtellg()没有返回正确的

对于PHP返回正确的时间感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解php返回正确的时间函数,并且为您提供关于API网关未返回正确的模板、c – ifstream tellg()没有返回正确的位置、c# – Json没有以所需的模式返回正确的值、c# – 匿名函数未返回正确的字符串的宝贵知识。

本文目录一览:

PHP返回正确的时间(php返回正确的时间函数)

PHP返回正确的时间(php返回正确的时间函数)

为了我的一生,我无法弄清楚如何正确地用PHP返回当前时间.首先,让我向您展示设置.

服务器本地时间在CST中

我在太平洋标准时间(PST),所以相差2小时.我还在服务器的htaccess中添加了以下语句:

SetEnv TZ Amercia /洛杉矶

好的,我的PHP语句拉当前时间是

<?PHP $t = time(); echo(date("D F d Y H:i:s",$t)); ?>

但是这段代码似乎要提前8小时返回…我不知道为什么吗?我希望它返回我的PST时间…

多谢你们!

解决方法:

在脚本中使用此功能.

date_default_timezone_set('America/Los_Angeles');

List of supported timezones

API网关未返回正确的模板

API网关未返回正确的模板

如何解决API网关未返回正确的模板?

映射模板存在一些奇怪的AWS问题。我的lambda返回一个json主体或404。当lambda返回一个主体时,该模板可以按预期工作,但是在404上,当我期望“ message”:“ test”来自

时,我什么也没回来
#set($inputRoot = $input.path(''$''))
{
  "message" : "test"
}

我的猜测是第一行,但我所做的任何更改都没有给我想要的结果。到目前为止,我的假设是,由于404没有返回任何内容,因此它永远无法替代。有什么想法吗?

编辑:404是直接通过集成请求而不是Lambda来自S3的,因为它找不到要返回的任何内容。我们不仅希望将404传递给客户,还希望传递一条消息以及详细信息。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

c – ifstream tellg()没有返回正确的位置

c – ifstream tellg()没有返回正确的位置

代码如下:

代码:

#include <iostream>
#include <fstream>

using namespace std;

int main(void)
{
    int id;
    char name[50];
    ifstream myfile("savingaccount.txt");  //open the file
    myfile >> id;
    cout << myfile.tellg(); //return 16? but not 7 or 8
    cout << id ;

    return 0;
}

文件内容:

1800567
Ho Rui Jang
21
Female
Malaysian
012-4998192
20,Lorong 13,Taman Patani Janam
Melaka
Sungai Dulong

问题 :

1.)我希望tellg()返回7或8,因为第一行1800567是7位数,所以流指针应该放在这个数字之后和字符串“Ho Rui Jang”之前,但是tellg()返回16为什么会这样?

解决方法

这似乎更像是编译器错误(可能是gcc)

使用以下代码: –

#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
    int id;
    char name[50];
    ifstream myfile("savingaccount.txt");  //open the file
    cout << myfile.tellg()<<endl;
    myfile >> id;
    streamoff pos=myfile.tellg();
    cout <<"pos= "<<pos<<'\n';
    cout <<"id= " << id<<'\n' ;
    return 0;
}

以下是输出: –

在图像中,inpstr.exe是从Visual Studio的cl生成的,而inp.exe是从g生成的(gcc版本4.6.1(tdm-1))

c# – Json没有以所需的模式返回正确的值

c# – Json没有以所需的模式返回正确的值

我需要这个作为我的json回归.这些数据是从数据库中提取的,但目前我正在使用静态数据.

{
        "data": [
            {
                "id": 1,"latitude":17.3700,"longitude": 78.4800,"gallery":
                    [
                        "assets/img/items/1.jpg"
                    ]
            }
        ]
    }

我已经在我的代码中尝试了这个但是我没有得到理想的结果.

[WebMethod]
    [ScriptMethod(UseHttpGet = true,ResponseFormat = ResponseFormat.Json)]
    public List<> getData()
    {
        Account account = new Account
        {
            id = 1,latitude = "17.3700",longitude ="78.4800",gallery = new List<string>
                  {
                    "assets/img/items/1.jpg","assets/img/items/2.jpg",}
        };
        return new JavaScriptSerializer().Serialize(account);
    }

    public class Account
    {
        public int id { get; set; }
        public string latitude { get; set; }
        public string longitude { get; set; }
        public IList<string> gallery  { get; set; }
    }

结果:

{
 "id":2,"latitude":"17.3700","longitude":"78.4800","gallery":["assets/img/items/1.jpg","assets/img/items/2.jpg"]
}

解决方法

您需要使用data属性创建一个新类:

public class Result { public object[] Data { get; set; } }

并返回:

public string getData()
{
    Result result = new Result
    {
        Data = new [] { new Account { id = 1,... } }
    };

    return new JavaScriptSerializer().Serialize(result);
}

c# – 匿名函数未返回正确的字符串

c# – 匿名函数未返回正确的字符串

我有以下代码:
delegate string CD();
void MyFunction()
{
    stringBuilder.Append((CD)delegate()
    {
        switch(whatever)
        {
            case 1 : return "A";
            ...
            default: return "X";
        }
    });
}

但是stringBuilder附加了文本MyNamespace.MyClass CD而不是A或X.为什么会发生这种情况?

解决方法

您在调用Append时声明了CD类型的委托,并在其上调用ToString(),默认情况下返回类型名称,即“MyNamespace.MyClass CD”.

您需要调用委托来进行评估,例如:

void MyFunction()
    {
        stringBuilder.Append(((CD)delegate
        {
            switch (whatever)
            {
                case 1:
                    return "A";
                    ...
                default:
                    return "X";
            }
        }).Invoke());
    }

今天关于PHP返回正确的时间php返回正确的时间函数的介绍到此结束,谢谢您的阅读,有关API网关未返回正确的模板、c – ifstream tellg()没有返回正确的位置、c# – Json没有以所需的模式返回正确的值、c# – 匿名函数未返回正确的字符串等更多相关知识的信息可以在本站进行查询。

本文标签: