• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
        • AdjLBA Function
        • AdjLBI Function
        • AdjUBA Function
        • AdjUBI Function
        • DateAdd Function
        • DateDiff Function
        • DateValid Function
        • PublishDate Function
        • SetLB Function
        • SetUB Function
        • SysDate Function
        • SysTime Function
        • timestamp Function
        • timestring Function
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

timestring Function

Format
s = timestring(ʃtimestamp_formatʅʃ, timestamp_valueʅ);
Description
The timestring function returns a formatted string containing the date and time as represented by a UNIX time, but using the local machine's time zone (instead of UTC).
The optional string expression timestamp_format contains date and time formatters. You can view a list of these formatters on a webpage about the C function strftime. If no formatter is supplied, the function returns an expression based on the machine's local settings using the formatter "%c" (note that the "%c" formatter is locale-dependent and so will return a slightly different layout depending on where it is invoked).
The optional numeric expression timestamp_value allows you to use a date/time value that came from the timestamp function. If not supplied, the function uses the current date/time.
If querying a SQLite database via the Sqlite.exec action or sqlquery function, you can call this function using the name cspro_timestring.
Return Value
The function returns the custom formatted date and time string.
Example
// if the current date (the default when no argument is given) is 12/27/2021,
// then the text displayed would be "Week 52"
errmsg("Week %s", timestring("%W"));

// if living in EST, the string will display "Fri May  5 08:00:00 2000"
numeric cspro_first_release_timestamp = 957528000;
errmsg("%s", timestring(cspro_first_release_timestamp));

// the following will display the string "Friday May 05, 2000"
errmsg("%s", timestring("%A %B %d, %Y", cspro_first_release_timestamp));
See also: timestamp Function, SysTime Function, SysDate Function