---
name: "Mango::BSON::Time"
section: "3pm"
platform: "linux"
package: "libmango-perl"
version: "1.30-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Mango::BSON::Time"
---

# Mango::BSON::Time(3pm)

Datetime type

## NAME

Mango::BSON::Time - Datetime type

## SYNOPSIS

```
  use Mango::BSON::Time;
  my $time = Mango::BSON::Time->new(time * 1000);
  say $time->to_epoch;
```

## DESCRIPTION

Mango::BSON::Time is a container for the BSON datetime type used by Mango::BSON.

## METHODS

Mango::BSON::Time inherits all methods from Mojo::Base and implements the following new ones.

### new

```
  my $time = Mango::BSON::Time->new;
  my $time = Mango::BSON::Time->new(time * 1000);
```

Construct a new Mango::BSON::Time object.

### TO\_JSON

```
  my $num = $time->TO_JSON;
```

Numeric representation of time.

### to\_datetime

```
  my $str = $time->to_datetime;
```

Convert time to RFC 3339 \<http://tools.ietf.org/html/rfc3339\> date and time.

### to\_epoch

```
  my $epoch = $time->to_epoch;
```

Convert time to floating seconds since the epoch.

### to\_string

```
  my $str = $time->to_string;
```

Stringify time.

## OPERATORS

Mango::BSON::Time overloads the following operators.

### bool

```
  my $bool = !!$time;
```

Always true.

### stringify

```
  my $str = "$time";
```

Alias for "to\_string".

## SEE ALSO

Mango, Mojolicious::Guides, \<http://mojolicio.us\>.
