http://qs321.pair.com?node_id=615728

rashmi_k28 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Date subroutine
by Tomte (Priest) on May 16, 2007 at 11:29 UTC

    What did you try? Why don't you read the documentation? Do you think your computer or we here should be able to read your mind?

    here is my testrun, everything works as it should - don't just make something up in your head and falter surrender if that failes, read the documentation carefully, experiment with the stuff you read and think:

    mysql> create table tstest( ts timestamp not null default now()); Query OK, 0 rows affected (0.03 sec) mysql> insert into tstest values(from_unixtime(114454234)); Query OK, 1 row affected (0.00 sec) mysql> select * from tstest; +---------------------+ | ts | +---------------------+ | 1973-08-17 17:50:34 | +---------------------+ 1 row in set (0.00 sec)

    Edit: altered a word to get nearer to the intended meaning...(marked via strike out)

    regards,
    tomte


    An intellectual is someone whose mind watches itself.
    -- Albert Camus

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Date subroutine
by naikonta (Curate) on May 16, 2007 at 10:56 UTC
    rashmi_k28, what date subroutine are you talking about? Does it come from CPAN module or your module? Are you talking about the date Linux command line?
    my $date = qx/date/;
    Are you looking for the equal of PHP date() function in Perl? There's no such built-in function in Perl, but jettero has shown an example as well. Or, there are various CPAN modules available to work with various aspects of date. You can also use the strftime() function in POSIX.
    use POSIX 'strftime'; my $today = strftime '%d-%m-%Y', localtime;

    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Date subroutine
by blazar (Canon) on May 16, 2007 at 12:09 UTC
    How to use the date subroutine.

    Is that a question? If so, then it's missing a question mark. However the answer is "just like thus:"

    my @output=date(@args);

    What should be in @args and what should end up in @output depends on the actual date sub.

    How to use the date subroutine and pass the value in other file

    Another question? Still missing a question mark. However the answer is "just like thus:"

    print $otherfile date(@args);
Re: Date subroutine
by jettero (Monsignor) on May 16, 2007 at 10:45 UTC
    use strict; use warnings; open my $otherfile, ">", "otherfile.txt" or die $!; print $otherfile scalar localtime, "\n";

    -Paul

Re: Date subroutine
by swampyankee (Parson) on May 16, 2007 at 15:29 UTC

    "How to use the date subroutine."
      Leaving out snarky comments about its object oriented interface, partner -> find_member_of_appropriate_sex
    and complaints about your punctuation, look to convert seconds since the epoch to a list containing the time and date, and the various time-related functions in the Posix module, where you could take a look at strftime and asctime.

    emc

    Insisting on perfect safety is for people who don't have the balls to live in the real world.

    —Mary Shafer, NASA Dryden Flight Research Center
Re: Date subroutine
by shmem (Chancellor) on May 16, 2007 at 11:27 UTC
    Please use the Chatterbox for such trivial one-shot questions. No need to start a thread.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}