Skip to content

Instantly share code, notes, and snippets.

@wemakeweb
Created February 21, 2012 17:25
Show Gist options
  • Save wemakeweb/1877538 to your computer and use it in GitHub Desktop.
Save wemakeweb/1877538 to your computer and use it in GitHub Desktop.
Php vs Js : Time Format
var now = new Date(),
hour, min;
if (this.data.time.format === "24") {
hour = now.getHours() + "";
min = now.getMinutes() + "";
if (hour.length === 1) {
hour = "0" + hour;
}
if (min.length === 1) {
min = "0" + min;
}
this.$container.append(hour + ":" + min + " Uhr <span></span>");
} else {
hour = now.getHours();
min = now.getMinutes() + "";
if (min.length === 1) {
min = "0" + min;
}
if (hour > 11) {
this.$container.append((hour - 12) + ":" + min + " PM <span></span>");
} else {
this.$container.append(hour + ":" + min + " AM <span></span>");
}
}
if ($data->config->clock_format == "12") {
echo date("g:h A");
} else {
echo date("G H") + " Uhr";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment