你知道如何将它转换为strtotime或类似的值传递给DateTime对象吗?
我有的日期:
Mon, 12 Dec 2011 21:17:52 +0000
Run Code Online (Sandbox Code Playgroud)
我尝试过的:
$time = substr($item->pubDate, -14);
$date = substr($item->pubDate, 0, strlen($time));
$dtm = new DateTime(strtotime($time));
$dtm->setTimezone(new DateTimeZone(ADMIN_TIMEZONE));
$date = $dtm->format('D, M dS');
$time = $dtm->format('g:i a');
Run Code Online (Sandbox Code Playgroud)
以上是不正确的.如果我循环了很多不同的日期,那就是同一天.
有没有办法可以使用我的匿名函数来设置数值?
$url = array('dog', 'cat', 'fish');
array_walk($url, function(&$value, &$key) {
$url[$key] = str_replace('dog', '', $value);
});
echo '<pre>';
print_r($url);
echo '</pre>';
Run Code Online (Sandbox Code Playgroud) 有谁知道我怎么能做内部连接和别名值,所以他们不会互相覆盖?如果你看到我的代码,它可能会更清晰:
SELECT home, away, g.network, g.date_start
FROM game g
INNER JOIN team t ON (
(t.importid = g.home) as home
OR
(t.importid = g.away) as away
)
ORDER BY date_start DESC
LIMIT 7
Run Code Online (Sandbox Code Playgroud)
已解决(以下帮助是我最后的查询)
SELECT
home.market AS home_market,
away.market AS away_market,
g.network,
g.date_start
FROM game AS g
INNER JOIN team AS home ON (
home.importid = g.home
)
INNER JOIN team AS away ON (
away.importid = g.away
)
ORDER BY g.date_start DESC
LIMIT 7
Run Code Online (Sandbox Code Playgroud) 我在CI Active Record的" Where Not In "中遇到了问题.我试图排除一系列ID.我无法理解为什么一切都运行良好,花花公子一个记录,但没有多个.
我的查询
$this->db->where_not_in('crm.user_id', $ignore);
Run Code Online (Sandbox Code Playgroud)
问题是当我分析查询是错误的时候.
带有一串ID
// $ignore = "12,13";
SELECT *
FROM (`crm`)
WHERE `crm`.`user_id` NOT IN ('16,13')
AND `survey` = 1
Run Code Online (Sandbox Code Playgroud)
带有一串引号ID
// $ignore = "'12','13'";
SELECT *
FROM (`crm`)
WHERE `crm`.`user_id` NOT IN ('\'16\',\'13\'')
AND `survey` = 1
Run Code Online (Sandbox Code Playgroud)
我被迫做了一个" or_where_not_in "或类似的循环吗?
我正在使用jQuery Validator.我想弄明白:一旦提交验证器,我怎么能从我的表单中取消附加?
$(function() {
// Just the rules, etc...
validator = $("#sweepstakesForm").validate({rules: {fname: {required: true,minlength: 2,maxlength: 50},lname: {required: true,minlength: 2,maxlength: 50},email: {email: true,remote: "?c=home&m=jsHook¶m=email&nojson=1",required: true,minlength: 6,maxlength: 120},address: {required: true,minlength: 5,maxlength: 100},state_0: {required: true},state: ); // etc ...
$('#sweepstakesForm').submit() {
}
});
Run Code Online (Sandbox Code Playgroud)
我试过这些无济于事:
validator = null;
$("#sweepstakesForm").unbind('validate');
delete validator;
Run Code Online (Sandbox Code Playgroud) 如果有人说的话,请原谅我不理解这一点.
为什么Angpen实现的Dependency Injector通过a使用注射剂
constructor
?
我习惯以DI
各种方式看待.即使是一种静态方法也是有意义的(如果存在对不起我还没挖到那么深,我到目前为止已经进入了一周).
以这种方式使用它会不会更容易或更合乎逻辑,更类似于我们经常看到但仍然在构造函数中传递它的DI?
// Non-Angular Example
@Component({})
class FooComponent {
public appState: AppState;
constructor(DI: DependencyInjector) {
this.appState = DI.get('AppState');
}
ngOnInit() {}
}
Run Code Online (Sandbox Code Playgroud)
Angular更像是这样,我不确定它是仅仅是为了冗长,还是有其他原因.
// Angular 2/4 Example
@Component({})
class BarComponent {
public appState: AppState;
constructor(appState: AppState,
router: Router,
etc: EtcSomething) {
}
ngOnInit() {}
Run Code Online (Sandbox Code Playgroud)
我知道谷歌已经想到了这一点,我只是想了解推理和/或好处.也许我醒来时想到了愚蠢的事情,这很明显,只是我的头脑,但我错过了.
我希望我所要求的是有道理的,我只是想知道为什么.
PHP有一个名为print_r()和var_dump()的函数,它将显示项目的所有内容.它可以很容易地弄清楚它是什么.
C#中有类似的东西吗?
我知道Console.WriteLine("Hello");
C#中有一个,但这在MVC中有效吗?我可以做一些类型的debug.trace()
像Flash并进入调试控制台,而我运行应用程序?
如何使用Dictionary而不是方法参数对Django模型进行过滤?这就是我在这里:
class StoreView(TemplateView):
def get(self, request):
# A bunch of gets
sort = request.GET.get('sort')
sort_price = request.GET.get('sort_price')
sort_mfr_method = request.GET.get('mfr_method')
# The params tpsort by
sort_params = {}
if sort is not None:
sort_params['sort'] = sort
if sort_price is not None:
sort_params['sort_price'] = sort_price
if sort_mfr_method is not None:
sort_params['sort_mfr_method'] = sort_mfr_method
# The Model Query
design_list = models.Design.objects.filter(sort_params)
# etc...
Run Code Online (Sandbox Code Playgroud)
Side Question,有没有比我上面做的更好的设置字典值的方法?比如三元,但是如果不存在那么价值就不存在了吗?
sort_params['sort'] = sort if not None else ''
Run Code Online (Sandbox Code Playgroud) 我正试图找到一种批量应用这些命名空间的方法,因为这样做不方便写出来.我知道我可以简单地使用,jream\ as j
但我希望看看是否可以避免反斜杠.
require '../jream/Autoload.php';
use jream\Autoload as Autoload,
jream\Database as Database,
jream\Exception as Exception,
jream\Form as Form,
jream\Hash as Hash,
jream\Output as Output,
jream\Registry as Registry,
jream\Session as Session;
new Autoload('../jream');
Run Code Online (Sandbox Code Playgroud)
有没有办法在这些方面说些什么:jream\\* as *;
?
任何提示将不胜感激:)
id_rsa
和id_rsa.pub
我的电脑也绑在我的BitBucket帐户.问题:我无法弄清楚如何让任何服务器接受公钥,你看到我做错了吗?
$ cat id_rsa.pub >> authorized_keys
$ service ssh restart (I suppose this isn't needed)
$ git pull origin master
$ Permission denied(publickey)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?我已经被困了好几天了.
php ×3
angular ×1
bitbucket ×1
c# ×1
codeigniter ×1
date ×1
date-format ×1
datetime ×1
django ×1
git ×1
jquery ×1
linux ×1
mysql ×1
namespaces ×1
select ×1
ssh-keys ×1
time-format ×1