1DateTime::Format::EpochU:s:eNrTPC(o3n)tributed Perl DocuDmaetnetTaitmieo:n:Format::Epoch::NTP(3)
2
3
4
6 DateTime::Format::Epoch::NTP - Convert DateTimes to/from NTP epoch
7 seconds
8
10 use DateTime::Format::Epoch::NTP;
11
12 my $dt = DateTime::Format::Epoch::NTP->parse_datetime( 3629861151 );
13 print $dt->datetime; # '2015-01-10T06:45:51'
14
15 my $formatter = DateTime::Format::Epoch::NTP->new();
16 my $dt = DateTime->new( year => 2015, month => 1, day => 10,
17 time_zone => 'Europe/Amsterdam' );
18 print $formatter->format_datetime($dt); # '3629833200'
19
21 This module can convert a DateTime object (or any object that can be
22 converted to a DateTime object) to the number of seconds since the NTP
23 epoch.
24
25 The NTP epoch uses UTC; if you parse an NTP date your DateTime object
26 will be using the UTC timezone.
27
29 Most of the methods are the same as those in DateTime::Format::Epoch.
30 The only difference is the constructor.
31
32 ยท new()
33
34 Constructor of the formatter/parser object. It has no parameters.
35
37 Support for this module is provided via the datetime@perl.org email
38 list. See http://lists.perl.org/ for more details.
39
41 Eugene van der Pijll <pijll@gmx.net>
42
44 Copyright (c) 2015 Michiel Beijen. This program is free software; you
45 can redistribute it and/or modify it under the same terms as Perl
46 itself.
47
49 DateTime
50
51 datetime@perl.org mailing list
52
53
54
55perl v5.32.0 2020-07-28 DateTime::Format::Epoch::NTP(3)