Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Date/Time translation

Featured Replies

I have the following string:

Sun, 07 Jun 2009 08:55:46 GMT

I need to convert this into date and time format. Is there an easy calc to accomplish this?

Edited by Guest

If it's *always* in that format then it should not be too hard. Look at the words in the string

2 - day

3 - month name

4 - year

5 - hour

6 - minute

7 - seconds

You'll need a bit of self-assembly to convert the month name into the month number, a case statement will do it.

For the time, it's in GST so you'll need to assemble the hh:mm:ss together then add or subtract the time zone offset from it to get the local time (if the local time is what's needed).

The calc to create a date or time would look something like this:


Let( 



[

text = fieldname ; 

dy = middlewords( text ; 2 ; 1 ) ; 

mname = middlewords( text ; 3 ; 1 ) ; 

mon = case( mname = "Jan" ; 1 ; mname = "Feb" ; 2 ; ... ) ; 

yr = middlewords( text ; 4 ; 1 ) ; 

hr = middlewords( text ; 5 ; 1 ) ; 

min = middlewords( text ; 6 ; 1 ) ; 

sec = middlewords( text ; 7 ; 1 ) ; 

zone = 0 ; /* <- insert the time zone offset hours here */



tmestmp = Timestamp ( Date( mon ; dy ; yr ) ; Time( hr ; min ; sec ) + zone ) ;



]



Date ( tmestmp ) 

// Time( tmestmp )



)

Note that the Case() for the month names isn't complete.

Edit: just realised that the calculation to account for the time zone may need to affect the date as well as the time. The calculation has been changed to account for this.

Can somebody check the logic behind this and confirm it works for times around midnight?

Edited by Guest
allowed for edge case around midnight

Well, I don't see the need for accounting for the time zone but I may be wrong. :smile2:

It seems it would be THEIR time zone regardless of what that is. And, because it doesn't list AM or PM, it should be military time. What I came up with is:

Date calculation (result is date):

Let ( [

m = 1 + Div ( Position ( "JanFebMarAprMayJunJulAugSepOctNovDec" ; MiddleWords ( text; 3 ; 1 ) ; 1 ; 1 ) ; 3 ) ;

d = MiddleWords ( text; 2 ; 1 ) ;

y = MiddleWords ( text; 4 ; 1 )

] ;

Date ( m ; d ; y )

)

Time calculation (result is time):

MiddleWords ( text ; 5 ; 1 )

  • Author

These were incredibly helpful. Thanks to you both :

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.