Skip to content

date manipulation capability is very limited with ansible #84736

Closed
@navneet-rathi

Description

@navneet-rathi

Summary

there is no module in ansible which can be helpful to manipulate dates easily like get date 1 day age or 1 week ago.need

Issue Type

Feature Idea

Component Name

to_datetime

Additional Information

      set_fact:
        currentdate_: "{{ '%Y-%m-%d' | strftime(ansible_date_time.epoch) }}"
        currentdate_hypen: "{{ '%Y-%m-%d' | strftime(ansible_date_time.epoch) }}"
        #formatted_date: "{{ current_date | strftime('%Y-%m-%d') }}"

    - name: Display the formatted date
      debug:
        msg: "Formatted date is {{ currentdate_ }}"
 
    - name: get yesterdays date
      ansible.builtin.shell: "date -d 'yesterday 13:00' '+%Y_%m_%d'"
      register: yesterday_


Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis issue/PR relates to a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions