小编sin*_*rba的帖子

PHP:使用DateTime类转换日期

我是PayPal IPN的约会对象

payment_date = 20:12:59 Jan 13, 2009 PST
Run Code Online (Sandbox Code Playgroud)

我怎么可以转换Y-m-d\TH:i:s\Z

我确实尝试过

$date = new DateTime($_POST['payment_date']);
$payment_date = $date->format('Y-m-d\TH:i:s\Z');
Run Code Online (Sandbox Code Playgroud)

但在我的数据库中,我只获得了 '0000-00-00 00:00:00'

谢谢

php time datetime date

2
推荐指数
1
解决办法
1462
查看次数

从json文件中提取值

我有一个从API输出的文件,它包含一个JSON.

{
    "result": {
        "id": "f34fdasdfaa4364adc42b3a57",
        "modified_on": "2018-06-02T17:08:17.106435Z"
    },
    "success": true
}
Run Code Online (Sandbox Code Playgroud)

我只需要id的值(在我的例子中是f34fdasdfaa4364adc42b3a57)

我会用bash做的:

#!/usr/bin/env bash

#Pseudocode
id=$(grep -Po '"id":.*?[^\\]",' id.txt)
# /Pseudocode
curl -X DELETE "https://www.example.com/delete/$id"
Run Code Online (Sandbox Code Playgroud)

我确实找到了以前的答案并得到了这个:用Unix工具解析JSON

但正确的答案提取键和值,我只会重视(不再操纵字符串)

谢谢您的帮助

bash json jq

2
推荐指数
1
解决办法
131
查看次数

Laravel 5.7:构建时目标不可实例化

我知道有很多答案,但我无法真正解决这个问题。

我确实按照这个答案(How to make a REST API First Web application in Laravel)在 Laravel 5.7 上创建存储库/网关模式

我在 github 上还有“项目”,如果有人真的想要 test/clone/see : https: //github.com/sineverba/domotic-panel/tree/development (开发分支)

应用\接口\Lan接口

<?php
/**
 * Interface for LAN models operation.
 */

namespace App\Interfaces;


interface LanInterface
{

    public function getAll();

}
Run Code Online (Sandbox Code Playgroud)

应用\提供商\服务提供商

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        /**
         * Solve the "Key too long" issue …
Run Code Online (Sandbox Code Playgroud)

php laravel

2
推荐指数
1
解决办法
2万
查看次数

div中的中心文本,背景不是100%宽度

我正在使用Bootstrap 3.

我需要将文本(h2)置于带背景的div中.我需要他的背景不是100%宽度.

我无法将它们置于列中(参见错误行为的屏幕截图).

在此输入图像描述

这是HTML:

<div class="col-sm-6">

            <div class="category-title">

                <h2>{{ @value->category }}</h2>

            </div>

</div>
Run Code Online (Sandbox Code Playgroud)

这是CSS:

    div.category-title{display:inline-block;
background-color:#E1001A;
padding:10px;
text-align:center;
margin:0 auto}

div.category-title > h2{color:#FFF;
text-align:center;
text-transform:uppercase;
font-size:200%;}
Run Code Online (Sandbox Code Playgroud)

谢谢

html css

1
推荐指数
1
解决办法
344
查看次数

Android Volley:在哪里添加重试策略和超时?

请,我不知道添加/编辑超时和重试策略的位置.基本上我会有3秒.超时,并将rety策略设置为零.

我正在使用在网络上找到的模式.

Controller.java

public class Controller extends Application {

    /**
     * Log or request TAG
     */
    public static final String TAG = "VolleyPatterns";

    /**
     * Global request queue for Volley
     */
    private RequestQueue mRequestQueue;

    @Override
    public void onCreate() {
        super.onCreate();
    }

    /**
     * @return The Volley Request queue, the queue will be created if it is null
     */
    public RequestQueue getRequestQueue() {
        // lazy initialize the request queue, the queue instance will be
        // created when it is accessed for …
Run Code Online (Sandbox Code Playgroud)

java android android-volley

1
推荐指数
1
解决办法
8762
查看次数

PHP:交换机代码中的错误评估

前言:$ state可以有3个可能的值:

  • 1)0(零,整数)
  • 2)'Set Level: 10 %'(字符串)
  • 3)'Set Level: 20 %' (字符串)

我有一个不能返回正确值的开关代码.

这是代码:

<?php

$state = 0;

switch ($state) {

            case 'Set Level: 10 %':

                $return = 1;

            break;

            case 'Set Level: 20 %':

                $return = 2;

            break;

            default:

                $return = 0;

            break;

        }

        echo 'return:';

        var_dump($return);
Run Code Online (Sandbox Code Playgroud)

这是小提琴:https://3v4l.org/IQ142

随着$state = 0它返回1而不是0默认.我也尝试删除默认值并强加案例0:但没有变化.

谢谢

注意:$state也可以作为字符串.为此,我需要检查字符串.

php

1
推荐指数
1
解决办法
53
查看次数

PHP:switch语句问题(错误返回)

我有这个方法:

private function convertStatusStringToIntZeroOrOne(string $status)
{

    $status = strtolower($status);

    switch ($status) {

        case "off":
        case "0":
        case 0:
            $int_status = 0;
            break;

        case "on":
        case "1":
        case 1:
            $int_status = 1;
            break;

        default:
            $int_status = 1;
            break;


    }

    return $int_status;
}
Run Code Online (Sandbox Code Playgroud)

$status参数是串"On"时(带O字母大写),返回0(零).

当然,我需要返回1.

谢谢

php switch-statement

1
推荐指数
1
解决办法
36
查看次数

Jquery:如果元素存在,则获取它

要检查某个元素(例如 DIV)是否存在,我使用以下命令:

if($('div#someId').length != 0)
{
   // make stuff
}
Run Code Online (Sandbox Code Playgroud)

现在,我的函数中需要该元素,但我不知道如何引用它。

例如(我知道这是一个愚蠢的例子,但它仅用于解释):

if($('div#chart-google').length != 0)
{
    var target = $(this).attr('id');
    google.drawChart(target,data,options);
}
Run Code Online (Sandbox Code Playgroud)

那么,我如何在我的脚本中引用它呢?

jquery

-1
推荐指数
1
解决办法
60
查看次数

Java/Android:如何格式化日期?

我喜欢SupportDate在我的PHP项目中有一个类,像工具箱一样使用它,所以我也会在我的Android项目中使用它.

长话短说:

这是SupportDate班级:

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

/**
 * Created by Alessandro on 28/06/2015.
 */
public class SupportDate {

    // Suppress default constructor for noninstantiability
    private SupportDate() {
        throw new AssertionError();
    }

    public static String getCurrentDate(String format) {
        if (format==null){
            format = "yyyy-MM-dd HH:mm:ss";
        }

        final SimpleDateFormat sdf = new SimpleDateFormat(format);
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        final String utcTime = sdf.format(new Date());

        return utcTime;
    }

    public static String formatDate(String date, String format){
        if (date==null){
            date = …
Run Code Online (Sandbox Code Playgroud)

java android

-1
推荐指数
1
解决办法
1069
查看次数

标签 统计

php ×4

android ×2

java ×2

android-volley ×1

bash ×1

css ×1

date ×1

datetime ×1

html ×1

jq ×1

jquery ×1

json ×1

laravel ×1

switch-statement ×1

time ×1