我想了解这种编码:
<?php
echo "<p><h2>";
echo date_default_timezone_set("Asia/Kuala_Lumpur");
echo date('d-m-Y h:i:s a',time())."</h2></p>";
?>
它确实可以正常工作并显示日期时间,但是我的问题是,它在日期e.g 1mm/dd/yyyy , 108/12/2018
的开头显示了额外的1,如何在开头删除数字1?
答案 0 :(得分:4)
您在<head>
<base href="https://cdn.rawgit.com/download/polymer-cdn/2.6.0.2/lib/">
<script src="webcomponentsjs/webcomponents-loader.js"></script>
<link rel="import" href="polymer/polymer.html">
<link rel="import" href="iron-ajax/iron-ajax.html">
<link rel="import" href="iron-form/iron-form.html">
<link rel="import" href="paper-card/paper-card.html">
</head>
<body>
<x-foo></x-foo>
<dom-module id="x-foo">
<template>
<iron-ajax auto
id="requestSchedules"
url="https://httpbin.org/anything"
method="POST"
handle-as="json"
content-type="application/json"
body='[{"id":1, "x":1},{"id":2, "x":2}]'
last-response="{{schedules}}">
</iron-ajax>
<template is="dom-repeat" items="[[schedules.json]]">
<paper-card heading="Schedule">
<div class="card-content">
<iron-form id="scheduleForm[[item.id]]"
on-iron-form-presubmit="_onIronFormPreSubmit"
on-iron-form-response="_onIronFormResponse">
<form action="https://httpbin.org/post">
<input name="name" type="text" placeholder="Name">
<button>Submit</button>
</form>
</iron-form>
</div>
</paper-card>
</template>
<pre>[[formResponse]]</pre>
</template>
</dom-module>
</body>
之前显示date_default_timezone_set("Asia/Kuala_Lumpur")
。从echo date('d-m-Y h:i:s a',time())
中删除echo
。
date_default_timezone_set("Asia/Kuala_Lumpur")
显示1。
echo date_default_timezone_set("Asia/Kuala_Lumpur")
输出:date_default_timezone_set("Asia/Kuala_Lumpur");
echo date('d-m-Y h:i:s a',time());
答案 1 :(得分:0)
您可以尝试-
#include<stdio.h>
int main(){
int a,b,lcm=1,small,gcd=1,done=0,i,j,large=1,div=0;
printf("Enter range\n");
printf("From:");
scanf("%d",&a);
printf("To:");
scanf("%d",&b);
int n=b-a+1;
int num[30];
for(i=0;i<n;i++){
num[i]=a+i;
}
//Finds LCM
while(!done){
for(i=0;i<n;i++){
if(num[i]==1){
done=1;continue;
}
done=0;
break;
}
if(done){
continue;
}
done=0;
large=1;
for(i=0;i<n;i++){
if(num[i]>large){
large=num[i];
}
}
div=0;
for(i=2;i<=large;i++){
for(j=0;j<n;j++){
if(num[j]%i==0){
num[j]/=i;div=1;
}
continue;
}
if(div){
lcm*=i;div=0;break;
}
}
}
done=0;
//Finds GCD
while(!done){
small=num[0];
for(i=0;i<n;i++){
if(num[i]<small){
small=num[i];
}
}
div=0;
for(i=2;i<=small;i++){
for(j=0;j<n;j++){
if(num[j]%i==0){
div=1;continue;
}
div=0;break;
}
if(div){
for(j=0;j<n;j++){
num[j]/=i;
}
gcd*=i;div=0;break;
}
}
if(i==small+1){
done=1;
}
}
printf("LCM = %d\n",lcm);
printf("GCD = %d\n",gcd);
return 0;
}
输出-
12-08-2018 03:16:29 pm