Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: system date

  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    system date

    how to extract system date?

    codes would be helpful.. thanks..

  • #2
    New Coder
    Join Date
    Sep 2002
    Location
    Up North (UK)
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hongyi,
    I think that following code give an example of the whole time structure:
    Code:
    $thetime = time;
    @thelocaltime = localtime $thetime;
    
    print "Year " . ($thelocaltime[5]+1900) . "\n";
    print "Month " . ($thelocaltime[4]+1) . "\n";
    print "Day $thelocaltime[3]\n";
    print "Hour $thelocaltime[2]\n";
    print "Mins $thelocaltime[1]\n";
    print "Seconds $thelocaltime[0]\n";
    print "Day of the week $thelocaltime[6]\n";
    print "Day of the year $thelocaltime[7]\n";
    print "Daylight savings " . ( $thelocaltime[8] ? "in force" : not in force) . "\n";

  • #3
    New to the CF scene
    Join Date
    Aug 2002
    Location
    PA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    #in sudo-code so you do some work if you dont know this allready

    somethings do suck about it. Like you have to add an if statement that checks if the $min is lower than 10, and if it is, you then have a value of '0' <--zero in the space before the actual minuite. This works if you leave the variable in front blank meaning as nothing.

    another problem might be with hours. The time thing counts in military time or whatever it is called. To fix this you have to make another if statement and say.

    if $hour>12 then $hour=$hour-12

    now if you also want to place the AM or PM then you would say.

    if $hour>12 then $hour=$hour-12, $am_or_pm='PM'
    else $am_or_pm='AM'


    i hope that made sence or that you coulde use this OR it actually works. this is more for if you want to format what the computer gives you.

    -MARK
    -TECHNOPHOBIA-


  •  

    Posting Permissions

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