Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Converting a Timestamp into a Date

Updated on 2025-01-10 GMT+08:00

Function Name

$timestamp_format(String A, String B)

Parameter Description

  • String A: timestamp to be converted. The value is a numeric string containing a maximum of 20 digits. You can also use the built-in function $timestamp() to obtain the current timestamp.
  • String B: date and time value, consisting of the year, month, day, hour, minute, second, and millisecond. Where,
    • Year: represented by letter "y" and consists of 4 characters.
    • Month: represented by letter "M" and consists of 1 to 2 characters.
    • Day: represented by letter "d" and consists of 1 to 2 characters.
    • Hour: represented by letter "H" and consists of 0 to 2 characters.
    • Minute: represented by letter "m" and consists of 0 to 2 characters.
    • Second: represented by letter "s" and consists of 0 to 2 characters.
    • Millisecond: represented by letter "S" and consists of 3 characters.
  • Table 1 Letters and corresponding parameter types

    Letter

    Date/Time Element

    Type

    Example

    G

    Era identifier

    Text

    AD

    y

    Year

    Year

    1996, 96

    M

    Month in a year

    Month

    July, Jul, 07

    w

    Week number in a year

    Number

    27

    W

    Week number in a month

    Number

    2

    D

    Day number in a year

    Number

    189

    d

    Day number in a month

    Number

    10

    F

    Week number in a month

    Number

    2

    E

    Day in a week

    Text

    Tuesday, Tue

    a

    am/pm flag

    Text

    PM

    H

    Hour number in a day (0–23)

    Number

    0

    k

    Hour number in a day (1–24)

    Number

    24

    K

    Hour number in am/pm (0–11)

    Number

    0

    h

    Hour number in am/pm (1–12)

    Number

    12

    m

    Minute number in an hour

    Number

    30

    s

    Second number in a minute

    Number

    55

    S

    Millisecond

    Number

    978

    z

    Time zone abbreviation

    Text

    PST, EST

    Z

    Time zone offset

    Text

    +800, -0530

    NOTE:
    1. Each letter has its own meaning and is case sensitive.
    2. If one of "H", "m", "s" is 0, the other two must also be 0.

    A date and time value can contain spaces, hyphens (-), slashes (/), and colons (:), but not escape characters, such as \n. Common formats include but are not limited to the following:

    • yyyy-MM-dd HH:mm:ss
    • yyyyMMddHHmmss
    • yyyyMMddHHmmssSSS
    • yyyy-M-d H:m:s
    • MM-dd-yyyy HH:mm:ss
    • MM/dd/yyyy HH/mm/ss
    • MM/d/yyyy H/mm/ss
    • MM/d/yyyy H/mm/ss SSS
    • yyyyMMdd SSS
    • yyyy-MM-dd HH:mm:ss SSS
    • yyyy-MM-dd HH:mm:ss
    • yyyy-MM-dd HH:mm
    • yyyy-MM-dd HH
    • yyyy-MM-dd
    • yyyy-MM
    • yyyy
    • yy
    • MM-dd HH
    • MM-dd
    • MM
    • dd
    • HH:mm:ss SSS
    • HH:mm:ss
    • HH:mm
    • HH
    • mm
    • mm:ss
    • ss
    • SSS

Function Description

Converts a timestamp into a date in the corresponding format. The timestamp is the total number of milliseconds from 1970-01-01 00:00:00 to the specified time.

Parameter A in the function supports the following types:

  • Date and time in the format listed in Parameter Description
  • Environment parameters
  • Local parameters
  • Other built-in functions

Parameter B in the function supports the following types:

  • Date and time in the format listed in Parameter Description
  • Environment parameters
  • Local parameters
  • Other built-in functions

Application Scenarios

The timestamp-to-date function can be used in the following scenarios for API automation:

  • Request URL
  • Request header
  • Request body
  • Checkpoint property
  • if condition
  • for loop interrupt condition

Example

  • Request URL

    As shown in the following figure, the value of date in the request URL is the timestamp-to-date conversion function. Parameter A in the function is the built-in function $timestamp() for obtaining the current timestamp. For details, see Obtaining the Current Timestamp. Parameter B is yyyy-MM-dd HH:mm:ss.

  • Request header

    As shown in the following figure, the value of date in the request header is the timestamp-to-date conversion function. Parameter A in the function is the environment parameter date, and parameter B is yyyyMMddHHmmss. For details about how to set environment parameters, see Setting Environment Parameters of an API Script.

  • Request body

    As shown in the following figure, the request body uses the timestamp-to-date conversion function. Parameter A in the function is 123456789, and parameter B is yyyyMMddHHmmssSSS.

  • Checkpoint property

    As shown in the following figure, the target value of the checkpoint property result is the timestamp-to-date function. Parameter A in the function is the built-in function $timestamp() for obtaining the current timestamp, and parameter B is MM/dd/yyyy HH/mm/ss.

  • if condition

    As shown in the following figure, the target value of the if condition is the timestamp-to-date function. Parameter A in the function is the built-in function $timestamp() for obtaining the current timestamp, and parameter B is MM/d/yyyy H/mm/ss SSS.

  • for loop interrupt condition

    As shown in the following figure, the target value of the for loop interrupt condition is the timestamp-to-date function. Parameter A in the function is the built-in function $timestamp() for obtaining the current timestamp, and parameter B is yyyyMMdd SSS.

Kami menggunakan cookie untuk meningkatkan kualitas situs kami dan pengalaman Anda. Dengan melanjutkan penelusuran di situs kami berarti Anda menerima kebijakan cookie kami. Cari tahu selengkapnya

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback