SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Generating UTC time

    I am trying to display the following select options. It displays a option value of all times during the day in 30 minute increments but I want the value to display the UTC time of that value.

    PHP Code:
     $options = array(); $min30=array('00','30');
        foreach (
    range(0,23) as $fullhour) {
           
    $parthour $fullhour 12 $fullhour 12 $fullhour;
            foreach(
    $min30 as $int){
                if(
    $fullhour 11){
                    echo 
    "<option value='UTC TIME HERE'>".$options[$fullhour.".".$int]=$parthour.":".$int." PM</option>";
                }else{
                    if(
    $fullhour == 0){$parthour='12';}
                    echo 
    "<option value='UTC TIME HERE'>".$options[$fullhour.".".$int]=$parthour.":".$int." AM</option>" ;
                }
            }
        } 
    Can anyone give me any advice?

  2. #2
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I imbed some sort of count function in there as well to generate the UTC time?

  3. #3
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I imbed some sort of count function in there as well to generate the UTC time?

  4. #4
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I imbed some sort of count function in there as well to generate the UTC time?

  5. #5
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suggest you to save time in correct format in DB if it's possible

  6. #6
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,065
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    What timezone is the server set to use?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Simplest solution would be either to update the php.ini to set the timezone for all your pages or to add it at the top of the script to set it just for that one page.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  8. #8
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you send example of what you mean?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •