note 83351 modified in function.mktime by danbrown

From: Date: Sun, 20 Jul 2008 03:27:31 +0000
Subject: note 83351 modified in function.mktime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142061@lists.php.net to get a copy of this message
This script is for creating servertime with auto detect server timezone. <?php $month = date(m); //* Get Current Month // $day = date(j); //* Get Current Day // $year = date(Y); //* Get Current Year // $hour = date(G); //* Get Current Hour (24 Hours Format) // $min = date(i); //* Get Current Minutes // $sec = date(s); //* Get Current Seconds // $gmt = date(O); //* Get Current Timezone // $servertime = date("D \\- M j\\, Y \\- g:i A", mktime($hour+$gmt, $minutes, $sec, $month, $day, $year, 0)); print $servertime; ?> If you want to input a multiple timezone. just copy the "$gmt = date(O). Then add increments to "$gmt" and replace the "date(O)" to any timezone you want. For example: I need only 2 timezone, Standard GMT and Pacific Timezone. I will remove "$gmt" and replace it with "$gmt1" and "$gmt2". Then for "$gmt1" I will replace the "date(O)" with 0, so my Timezone1 is equal to Standard GMT. Then for "$gmt2" I will replace the "date(O)" with -8, so my Timezone2 is equal to Pacific Timezone. To get the output for two timezone we need also two output script. <?php echo date("D \\- M j\\, Y \\- g:i A", mktime($hour+$gmt1, $minutes, $sec, $month, $day, $year, 0)); echo date("D \\- M j\\, Y \\- g:i A", mktime($hour+$gmt2, $minutes, $sec, $month, $day, $year, 0)); ?> Enjoy scripting, -JhunTech09 --was-- This script is for creating servertime with auto detect server timezone. <? php $month = date(m); //* Get Current Month // $day = date(j); //* Get Current Day // $year = date(Y); //* Get Current Year // $hour = date(G); //* Get Current Hour (24 Hours Format) // $min = date(i); //* Get Current Minutes // $sec = date(s); //* Get Current Seconds // $gmt = date(O); //* Get Current Timezone // $servertime = date("D \\- M j\\, Y \\- g:i A", mktime($hour+$gmt, $minutes, $sec, $month, $day, $year, 0)); print $servertime; ?> If you want to input a multiple timezone. just copy the "$gmt = date(O). Then add increments to "$gmt" and replace the "date(O)" to any timezone you want. For example: I need only 2 timezone, Standard GMT and Pacific Timezone. I will remove "$gmt" and replace it with "$gmt1" and "$gmt2". Then for "$gmt1" I will replace the "date(O)" with 0, so my Timezone1 is equal to Standard GMT. Then for "$gmt2" I will replace the "date(O)" with -8, so my Timezone2 is equal to Pacific Timezone. Wait we need an output. To get the output for two timezone we need also two output script. echo date("D \\- M j\\, Y \\- g:i A", mktime($hour+$gmt1, $minutes, $sec, $month, $day, $year, 0)); echo date("D \\- M j\\, Y \\- g:i A", mktime($hour+$gmt2, $minutes, $sec, $month, $day, $year, 0)); Enjoy scripting, -JhunTech09 http://php.net/manual/en/function.mktime.php

« previous php.notes (#142061) next »