1

我正在尝试返回今天的生日。这就是我现在所拥有的,它有效,但我需要获取月份和日期才能输入到语句中。我想也许我可以从本地时间获取它们,但这并没有成功。任何建议,将不胜感激。

sub author_birth {
    my ($self) = @_;
    my ($day,$month) = (localtime())[3..4];
    my $author_result = $self->search_like(
        {
            birth => '%03-20'
        },
        {
            select => [
                'id',
                'complete_name',
            ],

            #result_class => 'DBIx::Class::ResultClass::HashRefInflator'
        }
    );

    my @author_ids = ();
    while (my $row = $author_result->next) {
        push @author_ids, $row->id;
    }

    return $self->get_author_info_by_id(\@author_ids);

}
4

1 回答 1

2

我最终做了这样的事情。

my ($self) = @_;
my $conc = '%';
my $datetime = Time::Piece->new->strftime('%m-%d');
my $date = $conc . $datetime;
my $author_result = $self->search_like(
    {
        birth => $date,
    },
    {
        select => [
            'id',
            'complete_name',
        ],

        #result_class => 'DBIx::Class::ResultClass::HashRefInflator'
    }
);
于 2013-03-19T19:12:37.450 回答