'localtime' question

Discussion in 'Perl Misc' started by PadgeA@gmail.com, Aug 5, 2007.

  1. Guest

    Using Linux the following code :

    use POSIX qw(strftime);
    my $now = strftime "%Y%m%e", localtime;

    yields '20070805'

    Under Windows the same code yields:

    '200708'

    Any ideas on how to get the day of the month included using Windows?
     
    , Aug 5, 2007
    #1
    1. Advertising

  2. wrote:
    > Using Linux the following code :
    >
    > use POSIX qw(strftime);
    > my $now = strftime "%Y%m%e", localtime;
    >
    > yields '20070805'
    >
    > Under Windows the same code yields:
    >
    > '200708'
    >
    > Any ideas on how to get the day of the month included using Windows?
    >


    Strange, both of them should be: 200708 5

    If you want a leading zero on the day, use: '%Y%m%d'


    --
    Just my 0.00000002 million dollars worth,
    Shawn

    "For the things we have to learn before we can do them, we learn by doing them."
    Aristotle
     
    Mr. Shawn H. Corey, Aug 5, 2007
    #2
    1. Advertising

  3. On Aug 5, 12:11 pm, "Mr. Shawn H. Corey" <> wrote:
    > wrote:
    > > Using Linux the following code :

    >
    > > use POSIX qw(strftime);
    > > my $now = strftime "%Y%m%e", localtime;

    >
    > > yields '20070805'

    >
    > > Under Windows the same code yields:

    >
    > > '200708'

    >
    > > Any ideas on how to get the day of the month included using Windows?

    >
    > Strange, both of them should be: 200708 5


    strftime(3) says that the %e format flag is part of the Single Unix
    Specification.

    Maybe %e is possible on Windows, depending on your systems service
    packs/installs and the level of POSIX compliance they add.
     
    Skye Shaw!@#$, Aug 7, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen
    Replies:
    1
    Views:
    1,259
    Purl Gurl
    May 19, 2004
  2. Gerry George

    Time::localtime problems

    Gerry George, May 26, 2004, in forum: Perl
    Replies:
    2
    Views:
    1,183
    Joe Smith
    May 26, 2004
  3. Gerry George

    localtime problems with month

    Gerry George, May 26, 2004, in forum: Perl
    Replies:
    1
    Views:
    521
    Jeff Schwab
    May 26, 2004
  4. Raskolnikow

    simple question (itoa, localtime)

    Raskolnikow, Jul 23, 2003, in forum: C Programming
    Replies:
    2
    Views:
    419
    Martin Ambuhl
    Jul 23, 2003
  5. OleMacGeezer

    time.localtime() Format Question

    OleMacGeezer, Aug 20, 2006, in forum: Python
    Replies:
    1
    Views:
    485
    Greg Krohn
    Aug 20, 2006
Loading...

Share This Page