Created
February 21, 2012 17:25
-
-
Save wemakeweb/1877538 to your computer and use it in GitHub Desktop.
Php vs Js : Time Format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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